Tuesday, 28 May 2013

can I fill a listview with a list of my own class?

I want to fill a ListView with a LinkedList<String> of my own elements.
My class looks like this:
public class Foo {
    public String text;
}
this is my adapter and the list:
String[] fromColumns = {"X"};
int[] toViews = {android.R.id.text1};
mAdapter = new SimpleCursorAdapter(this,
        android.R.layout.simple_list_item_1, null,
        fromColumns, toViews, 0);
list = (ListView)findViewById(R.id.list);
list.setAdapter(mAdapter);
and I also have a LinkedList<Foo> elements; which I want to display in my list
Now the question: how to solve this?
I dont know what to write into the fromColumns to match my text value
I dont know how to bind my elements List to the list so it will be displayed

No comments:

Post a Comment