I have trying to get my multi-line spinner to work, thought I can not work out why it wont! (It just shows single line - so the text runs off the edge). I have read this, but still doesn't work.
Here is my multi_line_spinner.xml file;
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="false"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight" />
And my activity (part) xml file;
<Spinner
android:id="@+id/schoolSpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10" />
And here is where I programmtically set the Spinner
UPDATE: I get the data from an AsyncTask connecting to a remote server. (The data is successfully retrieved).
ArrayList<String> schoolName = new ArrayList<String>();
getTTData task = new getTTData();
task.execute("1");
try {
dataSchool = task.get();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int x = 0;
while(x<dataSchool.size()-1)
{
schoolName.add(dataSchool.get(x));
x++;
schoolID.add(dataSchool.get(x));
x++;
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, schoolName);
adapter.setDropDownViewResource(R.layout.multi_line_spinner);
schoolSpinner.setAdapter(adapter);
schoolSpinner.setOnItemSelectedListener(this);
Where schoolName is an ArrayList of strings. Any help is much appreciated!