This repository was archived by the owner on Sep 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbutton6.java
More file actions
74 lines (69 loc) · 2.92 KB
/
Copy pathbutton6.java
File metadata and controls
74 lines (69 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.dakshin.sqlite;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Spinner;
public class button6 extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_button6);
ArrayAdapter<String> adapter;
final Spinner cropSpinner=findViewById(R.id.Crop);
final String[] crops=getResources().getStringArray(R.array.crop_names);
ArrayAdapter<String> cropsAdapter=new ArrayAdapter<>(this,android.R.layout.simple_spinner_dropdown_item,crops);
cropSpinner.setAdapter(cropsAdapter);
cropSpinner.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if(i==0)
return;
populateListView(crops[i]);
}
});
}
public void populateListView(String Crop_Name)
{
String[] array;
ListView listView;
listView = findViewById(R.id.Season);;
switch (Crop_Name) {
case "Maize":
array = getResources().getStringArray(R.array.Maize);
break;
case "Paddy":
array = getResources().getStringArray(R.array.Paddy);
break;
case "Chillies":
array = getResources().getStringArray(R.array.Chillies);
break;
case "Banana":
array = getResources().getStringArray(R.array.Banana);
break;
case "Total Pulses":
array = getResources().getStringArray(R.array.TotalPulses);
break;
case "Cotton":
array = getResources().getStringArray(R.array.Cotton);
break;
case "Sugarcane":
array = getResources().getStringArray(R.array.SugarCane);
break;
case "Cholam":
array = getResources().getStringArray(R.array.Cholam);
break;
case "Groundnut":
array = getResources().getStringArray(R.array.GroundNut);
break;
default:
array = new String[]{"ERROR!"};
}
Adapter adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,array);
listView.setAdapter((ListAdapter) adapter);
}
}