I am putting class objects in a spinner view and can display them but what’s displaying is the full qualified class name of something like: wxyg.dash1.object.abc.adb93931. In my class I have the following properties; gridNickName, gridName, firstName, lastName, password, and loginURI. Is there some property I can set so what is DISPLAYED in the spinner view is one of these properties? The whole class object still needs to be in the list though. Do I have to adjust my adapter or something? The is what I have briefly.
//getting arrays from strings file
String[] regions;
Spinner gridSpinner;
Spinner regionSpinner;
ArrayList <Grid> al = new ArrayList<Grid>();
Grid Grid1 = new Grid("meet grid1", "GridHB5", "pqppq", "wdwd","wdwdww", "www.google.com");
Grid Grid2 = new Grid("meet grid2", "GridHB6", "zzz", "uuu", "secret1","www.ebay.com");
Grid Grid3 = new Grid("meet grid3", "GridHB7", "xxx", "dskd", "secret3","www.amazon.com");
Grid Grid4 = new Grid("meet grid4", "GridHB8", "qqq", "dsdsd", "secret4","www.me.com");
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView (R.layout.activity_f1);
setTitleFromActivityLabel (R.id.title_text);
//declaring variables
al.add(Grid1);
al.add(Grid2);
al.add(Grid3);
al.add(Grid4);
Button submitButton = (Button) findViewById(R.id.button1);
Button cancelButton = (Button) findViewById(R.id.button2);
//getting arrays from strings file
regions = getResources().getStringArray(R.array.regions_array);
// grids = getResources().getStringArray(R.array.grids_array);
this.gridSpinner = (Spinner) findViewById(R.id.gridSpinner);
this.regionSpinner = (Spinner) findViewById(R.id.regionSpinner);
//creating adapters for both spinners
final ArrayAdapter<Grid> dataAdapter = new ArrayAdapter<Grid>(this, android.R.layout.simple_spinner_item, al);
ArrayAdapter<String> regionAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, regions);
// drop down layout style with radio button type.
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
regionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// attaching data adapters to spinners
gridSpinner.setAdapter(dataAdapter);
regionSpinner.setAdapter(regionAdapter);
As always I really appreciate you guys looking at this for me. I’m sure this is an easy fix and there is probably a property I am not aware of.
Thanks again!
Define your own toString() method in your Grid class.