嗨,我的 android 应用程序中的 onItemClick 有问题。我试了一下,但我得到了一个错误。我希望在我的列表视图中从 sqlite 数据库中获取数据,并且可以单击此列表中的一个值以使用该值启动另一个活动。有关更多信息,请参阅我的代码:
我的活动:
public class ShowActivity extends ListActivity {
我的方法:
private void ladeDaten() {
Cursor KlassenCursor = mDatenbank.rawQuery(KLASSEN_SELECT_ROW, null);
startManagingCursor(KlassenCursor);
android.widget.SimpleCursorAdapter KlassenAdapter = new android.widget.SimpleCursorAdapter(this,
android.R.layout.simple_list_item_1,
KlassenCursor,
new String[] {"name"},
new int[] {
android.R.id.text1
});
setListAdapter(KlassenAdapter);
ListView lv = (ListView)findViewById(android.R.id.list);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent,View view,int position,long id){
Cursor cursor = (Cursor)parent.getItemAtPosition(position);
String item = cursor.getString(cursor.getColumnIndex("name"));
Intent intent = new Intent(this,ShowActivity.class); //here is the error
intent.putExtra("iteid", item);
startActivity(intent);
}
});
}
我的布局:...
</ListView>
...
我的错误:
The constructor Intent(new AdapterView.OnItemClickListener(){}, Class<ShowActivity>) is undefined
我能做些什么?:(
更新:
public void onItemClick(AdapterView<?> parent,View view,int position,long id){
Cursor cursor = (Cursor)parent.getItemAtPosition(position);
String item = cursor.getString(cursor.getColumnIndex("name"));
Intent intent = new Intent(ShowDayActitiy,ShowDayActivity.class); //here is the error
intent.putExtra("iteid", item);
startActivity(intent);
}
});
我想开始一个活动:(