I assume that the "parent" you are talking about is Spinner. In this case:
Spinner.getItemAtPosition(pos);
will always return the type of object that you filled in Spinner,.
Example of using CustomType: (Spinner is filled with elements of type "CustomType", so getItemAtPosition (...) returns CustomType)
Spinner spinner = (Spinner) findViewById(R.id.spinner1); CustomType [] customArray = new CustomType[] { .... your custom items here .... };
Another example of using String Array: (Spinner is filled with elements of type String), so getItemAtPosition (...) will return String)
Spinner spinner = (Spinner) findViewById(R.id.spinner1); String[] stringArray= new String[] { "A", "B", "C" };
source share