从微调器中选择一个值后,我希望让另一个值列表从所做的选择中填充微调器。例如:当用户单击微调器时,会出现值“主队、主队、主队其他”。用户单击其中之一,然后与该选择相关的玩家然后填充微调器。下面是填充的原始微调器的代码。
public class ExampleMain extends Activity {
JSONArray jsonArray = null;
JSONArray str_login = null;
public String kode;
public String Team_Name;
public String Home_team;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
JSONParser jParser = new JSONParser();
String link_url = "http://10.0.2.2/NPD/P_name.php";
JSONObject json = jParser.FunctionParser(link_url);
Spinner d11 = (Spinner)findViewById(R.id.doubles11);
Spinner d12 = (Spinner)findViewById(R.id.doubles12);
Spinner d21 = (Spinner)findViewById(R.id.doubles21);
Spinner d22 = (Spinner)findViewById(R.id.doubles22);
Spinner d31 = (Spinner)findViewById(R.id.doubles31);
Spinner d32 = (Spinner)findViewById(R.id.doubles32);
try {
jsonArray = json.getJSONArray("team");
final String[] items = new String[jsonArray.length()];
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
items[i]=jsonObject.getString("P_name");
}
ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
android.R.layout.simple_spinner_item, items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
d11.setAdapter(adapter);
adapter = new ArrayAdapter<String>(
this,android.R.layout.simple_spinner_item, items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
d12.setAdapter(adapter);
adapter = new ArrayAdapter<String>(
this,android.R.layout.simple_spinner_item, items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
d21.setAdapter(adapter);
adapter = new ArrayAdapter<String>(
this,android.R.layout.simple_spinner_item, items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
d22.setAdapter(adapter);
adapter = new ArrayAdapter<String>(
this,android.R.layout.simple_spinner_item, items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
d31.setAdapter(adapter);
adapter = new ArrayAdapter<String>(
this,android.R.layout.simple_spinner_item, items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
d32.setAdapter(adapter);
} catch (JSONException e) {
e.printStackTrace();
}
谢谢。