Search Results

Search found 1 results on 1 pages for 'user521469'.

Page 1/1 | 1 

  • Android: onListItemClick not getting called in ListActivity

    - by user521469
    I'm having problems with my first Android app. I have subclassed ListActivity, and I'm having no luck getting the overridden onListItemClick() to respond to click events. I've read focus can be a problem, but changing focus in the XML files does not seem to work. Here's the relevant bits of code. Anyone see what's I've buggered up? public class Notepadv1 extends ListActivity { private int mNoteNumber = 1; private NotesDbAdapter mDbHelper; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.notepad_list); mDbHelper = new NotesDbAdapter(this); mDbHelper.open(); fillData(); } private void fillData() { // Get all of the notes from the database and create the item list Cursor c = mDbHelper.fetchAllNotes(); startManagingCursor(c); String[] from = new String[] { NotesDbAdapter.KEY_TITLE }; int[] to = new int[] { R.id.text1 }; SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to); setListAdapter(notes); } @Override public void onListItemClick (ListView l, View v, int position, long id){ super.onListItemClick(l, v, position, id); AlertDialog alert = new AlertDialog.Builder(this).create(); String message = "row clicked!"; alert.setMessage(message); alert.show(); } notepad_list.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> <ListView android:id="@android:id/list" android:layout_width="wrap_content" android:layout_height="wrap_content" android:dividerHeight="6dp"/> <TextView android:id="@android:id/empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_notes" /> </LinearLayout> And notes_row.xml <?xml version="1.0" encoding="utf-8"?> <TextView android:id="@+id/text1" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="60dp" android:focusable="false"/>

    Read the article

1