开发者

Listview using arraylist

开发者 https://www.devze.com 2023-02-24 02:37 出处:网络
How can we create the listview using arraylist in a simp开发者_JAVA技巧le wayListView lv=(ListView)findViewById(R.id.lv01);String[] names = new String[] { \"Show Hidden Files\", \"Suffle Tab Position\

How can we create the listview using arraylist in a simp开发者_JAVA技巧le way


ListView lv=(ListView)findViewById(R.id.lv01);  String[] names = new String[] { "Show Hidden Files", "Suffle Tab Position"};

    // Create an ArrayAdapter, that will actually make the Strings above
    // appear in the ListView
    this.setListAdapter(new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_checked, names));


I'd use a BaseAdapter, and override the necessary methods to make it use the ArrayList<?>.

In this post the MyELAdapter is used for an expandable list view, but the base logic is there, it populates the listview with Parent instances from an ArrayList<Parent>.

0

精彩评论

暂无评论...
验证码 换一张
取 消