问题描述:

This question already has an answer here:

  • What is “android.R.layout.simple_list_item_1”?

    7 answers

网友答案:

Regarding your question, you have two options.

1) Something really simple that'll toString() your Item objects in each row.

ArrayAdapter<Item> adapter = new ArrayAdapter<Item>(
    MainActivity.this, // Context
    android.R.layout.simple_list_item_1, // An XML file for your items
    Item.items         // The Item[] array
);
listView.setAdapter(adapter);

2) Define your own adapter class with your own XML


If you know how to use ListActivity, you can still show other elements, by the way.

Read the documentation.

if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id "@android:id/list"

相关阅读:
Top