0

I have a ListView which is created with SimpleCursorAdapter. The list represents merchants. When someone clicks on a merchant i want to view full details of this particular merchant.

on this list (lv1) im setting a listener

lv1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> av, View v, int pos, long id) {

            //Cursor merchant = (Cursor) adapter.getItem(pos);

            Intent merchant = new Intent(v.getContext(), MerchantView.class);
            merchant.putExtra("merchantPosition", pos);
            startActivity(merchant);
        }
    });
  1. How should I pass the data to merchant view in most optimal way?

  2. I have static reference to adapter so I guess I could use somehow getItem call (just as in commented out line) and then pass it as putExtra to Merchant. If that is the way to do it how should I use getItem (I tried couple of times but failed to extract data that i want).

P.S Adapter is making sql query earlier to database with columns - ID,NAME,DESCRIPTION,STATUS

Thanks!

AndroidGecko
  • 14,034
  • 3
  • 35
  • 49

1 Answers1

0

What I do in my Apps, is override the SimpleCursorAdapter.setViewBinder() to set the Tag of Views inside the ListView with the ID from the DB and pass this ID to the intent in the setOnItemClickListener(). Check this question which is a similar case to what you want to do

Community
  • 1
  • 1
Mohamed_AbdAllah
  • 5,311
  • 3
  • 28
  • 47