Is there a super simple List / ListAdapter example out there for android

前端 未结 3 808
天命终不由人
天命终不由人 2020-12-13 20:24

I have a web service that returns a super simple list of objects

MyObject[] data = webServiceCall();

MyObject has 1 field i want to display, \"Name\"

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 20:46

    make your Activity extends ListActivity as well.

    Then this should help you get started.

    Object[] sArray = {"This", "is", 3.5, true, 2, "for", "bla"};
    ArrayAdapter adp = new ArrayAdapter(this, android.R.layout.simple_list_item_1, sArray);
    setListAdapter(adp);
    

    The second parameters can be change to your preferred layout. See API document for further information.

提交回复
热议问题