0

Possible Duplicate:
Populating a ListView using ArrayList?

I'm trying to create a listview in android and i have a ArrayList that contain all list data but i'm facing problem showing data in listview. Anyone explain me how it can be possible. Please refer some example too. Thanks.

2

1 Answer 1

5

For suppose listitems is the arraylist then you need to append your arraylist to listview as

//Declaration part
ArrayAdapter<String> adapter;
ArrayList<String> listItems=new ArrayList<String>();
lv  =(ListView)findViewById(R.id.listView1);

//arraylist Append
adapter=new ArrayAdapter<String>(From.this,
            android.R.layout.simple_list_item_1,
            listItems);
lv.setAdapter(adapter);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.