當我想驗證插入時,檢索微調器的值時出現問題。在驗證後檢索微調器的值
這裏是我如何填寫我的微調:
ArrayList<HashMap<String, String>> myArrayList;
myArrayList= new ArrayList<HashMap<String, String>>();
for (int i = 0; i < studentList.length(); i++) {
JSONObject c = studentList.getJSONObject(i);
String id = c.getString("id");
String name = c.getString("name");
HashMap<String, String> map = new HashMap<String, String>();
map.put("id", id);
map.put("name", name);
myArrayList.add(map);
}
後:
SpinnerAdapter studentAdapter = new SimpleAdapter(
MyActivity.this, myArrayList,
R.layout.student, new String[] { "id", "name"},
new int[] { R.id.id, R.id.name });
mySpinner.setAdapter(studentAdapter);
當我點擊我的「確定」按鈕,我也得到了微調與
值mySpinner.getSelectedItem().toString();
我得到:
{ID = 2,名稱=史密斯}
但我敢肯定還有另一種方法僅檢索名稱,但如何?通過使微調器獲得適配器?這是我的問題...
謝謝
它的工作原理!非常感謝你:) – user2021346 2013-03-08 21:53:48
樂意幫忙。請將此答案標記爲已接受,以便其他人可以快速查看爲您解決的問題。 – Blumer 2013-03-08 22:01:15