I have a small application that retrieves data from a server. This is done with an function i've build. This function returns a List<string>
.
Now the issue that i am having.
I want to insert the list that i retrieve from my function into a ListView
.
I'm using the code below to try this:
List<string> range = _connection.GetData("animals");
ArrayAdapter adapter = new ArrayAdapter<String>(this,Resource.Layout.dataView, range);
listView.SetAdapter (adapter);
Range is the list that i get from my function GetData()
Now i want to insert the data from the range list into my listview but as soon as i start the application en press the button to do this the application shuts down with this message The application has stopped unexpectedly. Please try again.
.
Can someone tell me what i am doeing wrong here or show me how i can insert the data into my listbox.
Edit
I checked the ouput of the application and it says the following:
[AndroidRuntime] java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
So i know why the application shuts down. Can someone show me or tell me how i have to insert the data because the adapter requires an Textview to work.
Edit
This is my XML for my listview
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/dataListView" />
Thanks in advance
Final Edit 10/9/2014
After a lot of research en being pointed in the right direction i finnaly found out what i was doeing wrong.
This is how you insert data into an listview:
ArrayAdapter adapter = new ArrayAdapter(this,Android.Resource.Layout.SimpleListItem1, response);
listView.Adapter = adapter;
The problem was that i used an outdated function SetAdapter()
To everyone in the comments/ awnsers thanks for the help.