您交給ArrayAdapter的資源不應該是ListView的ID。它應該是textViewResourceId
--基本上你想讓你的項目在列表中顯示爲TextView-layout-id。
其中一個標準是例如android.R.layout.simple_list_item_1
。
這裏有一個簡單的ListView的例子:
public class ListviewExample extends Activity
{
private ListView listView;
private String listView_data[] = {"Android","iPhone","BlackBerry","AndroidPeople"};
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.main);
listView = (ListView) findViewById(R.id.ListView1);
// By using setAdapter method in listview we add the string array to the ListView.
listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1 , listView_data));
}
}
http://developer.android.com/resources/tutorials/views/hello-listview.html –