BABU K
BABU K

Reputation: 917

Find Listview clicked section adapter in mergeadapter?

I am using merge adapter to merge two custom cursor adapters in android.I could not find clicked section to get data from my custom cursor adapter.How can I get adapter object when listview clicked?. I tried following way in my onitemclick of listview. But it does not print "clicked on mention question section" text.But it returns [email protected] can I find which section is clicked in listview?

if (parent.getAdapter().getItem(position) instanceof FeedMentionQuestionAdapter) {
        LivLog.info(getClass(), "clicked on mention question section  ");

    }

Upvotes: 1

Views: 340

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006869

How can I get adapter object when listview clicked?

You need to hold onto your own adapter, or call getAdapter() on your ListView.

But it returns android.content.ContentResolver$CursorWrapperInner@41b9a638

Presumably, you put a CursorAdapter in the MergeAdapter.

Also, getItem() will never return an adapter. It returns items. If you are trying to determine the adapter that handles a particular position, call getAdapter().

How can I find which section is clicked in listview?

If you are referring to SectionIndexer, then sections are not clicked.

Upvotes: 1

Related Questions