I cannot figure out how to get a context menu when using a class
derived from CursorAdapter in my ListActivity.
Using a SimpleCursorAdapter works fine ...

    onCreate(Bundle b) {
    ...
        SimpleCursorAdapter sca = new SimpleCursorAdapter(...);
        setListAdapter(sca);
        registerForContextMenu(getListView());
    }

Overriding onCreateContextMenu(...) and onContextMenuItemSelected(...)
all work fine with the context menu behaving as expected (ie appearing
an functioning)
However, changing to use a class derived from CursorAdapter results in
no callbacks to either of the two above methods. I have noticed that
in this version the List View items don't get 'highlighted' when I
click on them - so there is probably some problem in linking the View
created in the CursorAdapter back to the register function

Here is the code

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.adapted_list);

        mDbHelper = new MyDbAdapter(this);
        mDbHelper.open();

        Cursor cursor = mDbHelper.getAllEntries();
        startManagingCursor(cursor);

        setListAdapter(new CheckBoxAdapter(this, cursor));
        registerForContextMenu(getListView());
    }

CheckBoxAdapter derives from CursorAdapter and implements the newView
and bindView overrides. The objective being to have each list row as a
number of widgets (text, checkBox) etc. This part is working fine
including the callback to the checkBox.  I've not shown
onCreateContextMenu(...) and onContextMenuItemSelected(...)  as they
are not being called.

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to