DataAccess data = new DataAccess(db);
List<String> countries = data.getCountries();
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();
}
});
如何從onItemClick
方法內部傳遞和訪問data
變量?將數據傳遞給OnItemClickListener?
不錯的解釋..... – 2011-04-19 04:21:13