我有3个微调器,用于填充Board,Class和Subject。根据选择的板子,对班级进行过滤;基于选择的板子,对主题名称进行过滤并显示在微调器中。我正在使用一条更新语句,其中首先向用户显示一个列表。单击列表项后,将检索详细信息,并且必须在相应的文本字段中填写。上述微调人员必须根据详细信息显示适当的董事会,班级和学科名称
我能够检索所有详细信息,并能够用板名来填充“板微调器”。但是无法填充“班级和主题”微调器
/**
Retrieves all the classes based on Board name selection
**/
try {
JSONObject jsonObject = new JSONObject(s);
final JSONArray jsonArray = jsonObject.getJSONArray("PopulateMultiListInfoResult");
int length2 = jsonArray.length();
List<String> class_list = new ArrayList<String>(length2);
class_list.add("Select Class");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject1 = jsonArray.getJSONObject(i);
class_list.add(jsonObject1.getString("NAME"));
cboClass.setAdapter(new ArrayAdapter<String>(ManagementCurriculumSetup.this,
android.R.layout.simple_list_item_1, class_list));
cboClass.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
try {
position = position - 1;
iClassID = jsonArray.getJSONObject(position).getString("ID");
/**
Method to populate Subject names based on Board and Class name selection
**/
populateSubjectInfo(iBoardID, iClassID);
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
} catch (JSONException e) {
e.printStackTrace();
}
}
/**
retrieve details based on the list item selected by the user
**/
try {
JSONObject jsonObject = new JSONObject(s);
JSONArray jsonArray = jsonObject.getJSONArray("RetrieveCurriculumDetailsResult");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject1 = jsonArray.getJSONObject(i);
//String sSyllabusDetails = Html.fromHtml(jsonObject1.getString("SYLLABUS_DETAILS")).toString();
txtSectionTitle.setText(jsonObject1.getString("SECTION_TITLE"));
txtSyllabusDetails.setText(jsonObject1.getString(jsonObject1.getString("SYLLABUS_DETAILS")));
txtWeightageFocus.setText(jsonObject1.getString("MARK_FOCUS"));
txtSessionDurationAllocation.setText(jsonObject1.getString("SCHEDULED_DURATION"));
cboBoard.setSelection(getIndex(cboBoard, jsonObject1.getString("BOARD_ID")));
cboClass.setSelection(getIndex(cboClass, jsonObject1.getString("CLASS_NAME")));
cboSubject.setSelection(getIndex(cboSubject, jsonObject1.getString("SUBJECT_NAME")));
}
} catch (JSONException e) {
e.printStackTrace();
}
/**
method to pre-populate spinner with a particular value based on list item selection
**/
private int getIndex(Spinner spinner, String myString) {
int index = 0;
for (int i = 0; i < spinner.getCount(); i++) {
if (spinner.getItemAtPosition(i).toString().equalsIgnoreCase(myString)) {
index = i;
break;
}
}
return index;
}
我只能用选定的列表项填充板名称。类别和主题名称未填充