我有一个带有ID和标题的微调器,我希望在微调器的每个部分显示ID更大,标题更小。
我该怎么做?
Spinner spinner = (Spinner)findViewById(R.id.spinner1);
ArrayList<String> spinnerArray = new ArrayList<String>();
for(int i = 0; i<jArray.length();i++){
JSONObject json_data = jArray.getJSONObject(i);
spinnerArray.add(json_data.getString("SessionId"));
map.put(json_data.getString("SessionId"), json_data.getString("Title"));
}
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item, spinnerArray);
spinner.setAdapter(spinnerArrayAdapter);
我想要的例子:
答案 0 :(得分:1)
修正了它。
ArrayList<Map<String, String>> spinnerArray = new ArrayList<Map<String, String>>();
for(int i = 0; i<jArray.length();i++){
JSONObject json_data = jArray.getJSONObject(i);
Map<String, String> data = new HashMap<String, String>(2);
data.put("SessionId", json_data.getString("SessionId"));
data.put("Title", json_data.getString("Title"));
spinnerArray.add(data);
//map.put(json_data.getString("SessionId"), json_data.getString("Title"));
Button button1 = (Button)findViewById(R.id.Submit);
button1.setEnabled(true);
}
SimpleAdapter adapter = new SimpleAdapter(this, spinnerArray, android.R.layout.two_line_list_item,
new String[] {"SessionId", "Title"},
new int[] {android.R.id.text1,
android.R.id.text2});
spinner.setAdapter(adapter);