hi I have a problem with the onItemClick in my android application. i try it but i get a error. I want that I get data from sqlite database in my listview and can click on a value in this list to start a other actitiy with this value. see my code for more information:
my actitiy:
public class ShowActivity extends ListActivity {
my method:
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);
}
});
}
my layout : ...
</ListView>
...
my error:
The constructor Intent(new AdapterView.OnItemClickListener(){}, Class<ShowActivity>) is undefined
what can I do? :(
UPDATE:
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);
}
});
i want do start a ther actitiy :(
Change this
Intent intent = new Intent(this,ShowActivity.class);
to
Intent intent = new Intent(ShowActivity.this,ShowActivity.class);