R0b0tn1k
R0b0tn1k

Reputation: 4306

Android: How to create an onclick event for a SimpleCursorAdapter?

I have this code:

    db=(new DatabaseHelper(this)).getWritableDatabase();
    constantsCursor=db.rawQuery("SELECT _ID, title, subtitle, image "+
                                                            "FROM news ORDER BY title",
                                                            null);

    ListAdapter adapter=new SimpleCursorAdapter(this,
                                                R.layout.row, constantsCursor,
                                                new String[] {"title", "subtitle", "image"},
                                                new int[] {R.id.value, R.id.title, R.id.icon});

    setListAdapter(adapter);
    registerForContextMenu(getListView());

Which displays a list of titles. I dont however for the life of me know how to create a click event so that i can call another view when i click an item from that list.

Anyone?

Upvotes: 0

Views: 2339

Answers (1)

m6tt
m6tt

Reputation: 4223

If you are extending a ListActivity then you can implement the onListItemClick method. See: http://d.android.com/reference/android/app/ListActivity.html#onListItemClick

Upvotes: 3

Related Questions