I have a spinner, with ID and Title, I want on every section of the spinner to show ID bigger up, and the title smaller under it.
How do I do this?
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);
example of what I want:
Fixed it.
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.