Im trying to start a new intent on clicking an item in a listview but dont know how to get this working.
Here is the code:
final ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
@SuppressWarnings("unchecked")
Intent intent = new Intent(this, Profileviewer.class);
startActivity(intent);
}
});
I get an compiller error on new Intent(this, Profileviewer.class);
The constructor Intent(new AdapterView.OnItemClickListener(){}, Class<Profileviewer>) is undefined
You should pass to the intent the context of the activity (by putting
YourActivity.this), by passing only this, you are passing theAdapterView.OnItemClickListener()..