我已經關注this tutorial,但是當我嘗試運行應用程序時,我得到Unfortunately HelloListView has stopped
IDE沒有提供警告或錯誤。不幸的是,HelloListView已停止
我HelloViewListActivity.java看起來是這樣的:
public class HelloListViewActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] countries = getResources().getStringArray(R.array.countries_array);
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, countries));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// When clicked, show a toast with the TextView text
Toast.makeText(getApplicationContext(),
((TextView) view).getText(), Toast.LENGTH_SHORT).show();
}
});
}
}
我的strings.xml和list_item.xml都是identical to the tutorial.
Logcat log here 它是什麼,我做錯了什麼?
看來你的list_content_simple.xml不正確。再次驗證一次。 – kosa
@thinksteep list_content_simple.xml沒有在教程中提到。我確實找到了它的SDK文件夾,並將其添加到我的res /佈局,但仍然是相同的錯誤。 – darren
你所指的教程有點零碎。現在查看我的答案。我已經包含了工作示例教程的鏈接,如果您不需要,可以忽略數據庫部分。 – kosa