Hi guys,

I use a SimpleCursorAdapter like this;

        @Override
        public void onCreate(Bundle icicle) {
                super.onCreate(icicle);
                this.getIntent().getIntExtra("category", -1);
                Integer category = this.getIntent().getIntExtra("category",
-1);
                SqliteFilterMediator mediator = new
SqliteFilterMediator(this);
                ListAdapter adapter =
                        new SimpleCursorAdapter(this,
                                        R.layout.row,
                                        c,
                                        new String[] {column},
                                        new int[] {R.id.name});
                setListAdapter(adapter);
        }

        public void onListItemClick(ListView parent, View v, int position,
long id) {
           // Position doesn't necessarily map to _id
            setResult(RESULT_OK, this.getIntent().putExtra("_id",
position));
            finish();
        }

I want to return the 'id' which is paired with the text on the ListItem in
the database (And in the cursor). Currently I return the position of the
list item clicked.

The cursor might return items with ids that are out of order with the
position of the list, or it could contain gaps in the sequence of integers,
as such the position isn't enough to map to the id of the row selected in
the database so that I can act acordingly.

I hope my situation makes sense, I think it might involve displaying the id,
casing the view clicked and somehow grabbing the displayed integer back as
the id, this seems a bit ridiculous though so I'm hoping there is a simpler
way to retrieve the id without making another database query.

Many thanks!

Gav

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to