{
"Platforms": [
{
"PlatformNo": "1",
"SerialNumbers": [
{
"Aplilevel": "1",
"Version": "1.0"
},
{
"Aplilevel": "2",
"Version": "1.1"
},
{
"Aplilevel": "3",
"Version": "1.5"
},
{
"Aplilevel": "4",
"Version": "1.6"
}
]
},
{
"PlatformNo": "2",
"SerialNumbers": [
{
"Aplilevel": "5",
"Version": "2.0"
},
{
"Aplilevel": "6",
"Version": "2.0.1"
},
{
"Aplilevel": "7",
"Version": "2.1.x"
},
{
"Aplilevel": "8",
"Version": "2.2.x"
},
{
"Aplilevel": "9",
"Version": "2.3"
},
{
"Aplilevel": "10",
"Version": "2.3.3"
}
]
},
{
"PlatformNo": "3",
"SerialNumbers": [
{
"Aplilevel": "11",
"Version": "3.0.x"
},
{
"Aplilevel": "12",
"Version": "3.1.x"
},
{
"Aplilevel": "13",
"Version": "3.2"
}
]
},
{
"PlatformNo": "4",
"SerialNumbers": [
{
"Aplilevel": "14",
"Version": "4.0"
},
{
"Aplilevel": "15",
"Version": "4.0.3"
}
]
}
]
}
上面显示的 JSON 是我需要在 PlatformNo 的微调器中显示的输出。当我选择一个项目时,我是否需要在另一个微调器中获取相应的 API 级别?谁能帮我解决这个问题?我试图在下面得到它,但我无法正确地得到它。我只在下一个微调器中获得最后一个值。有没有办法检查这个?请帮我。
String[] platfromno,apilevel;
Spinner splatform,sapilevel;
JSONObject obj = json.getJSONObject("Result");
JSONArray platformObject = customerObject.getJSONArray("Platforms");
String parray = customerObject.getString("Platforms");
System.out.println("String of Platforms array is " + parray);
for (int i = 0; i < productNameObject.length(); i++) {
JSONObject e = productNameObject.getJSONObject(i);
platformno[i] = e.getString("PlatformNo");
ArrayAdapter<String> spinnerPlatfromNo =
new ArrayAdapter<String>( this,
android.R.layout.simple_spinner_dropdown_item,
platformno);
splatform.setAdapter(spinnerPlatfromNo);
JSONArray serialNumberObject = e.getJSONArray("SerialNumbers");
apilevel= new String[serialNumberObject.length()];
splatform.setOnItemSelectedListener(
new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0,
View arg1, int arg2, long arg3) {
System.out.println("selected Item position is " +
splatform.getSelectedItemPosition());
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
// if (splatform.getSelectedItemPosition()) {
for (int j = 0; j < serialNumberObject.length(); j++) {
JSONObject e1 = serialNumberObject.getJSONObject(j);
apilevel[j] = e1.getString("Aplilevel");
// }
}