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.

Community
  • 1
  • 1
Rvg.2ky
  • 280
  • 1
  • 3
  • 12

1 Answers1

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);
Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78