我正在使用合并适配器在 android 中合并两个自定义光标适配器。我找不到单击的部分以从我的自定义光标适配器获取数据。单击 ListView 时如何获取适配器对象?。 我在 ListView 的 onitemclick 中尝试了以下方式。但它不打印“点击提及问题部分”文本。但它返回 android.content.ContentResolver$CursorWrapperInner@41b9a638。如何找到在 ListView 中点击了哪个部分?
if (parent.getAdapter().getItem(position) instanceof FeedMentionQuestionAdapter) {
LivLog.info(getClass(), "clicked on mention question section ");
}
最佳答案
How can I get adapter object when listview clicked?
您需要保留自己的适配器,或在您的 ListView
上调用 getAdapter()
。
But it returns android.content.ContentResolver$CursorWrapperInner@41b9a638
据推测,您在 MergeAdapter
中放置了一个 CursorAdapter
。
此外,getItem()
永远不会返回适配器。它返回项目。如果您试图确定处理特定 位置
的适配器,请调用 getAdapter()
。
How can I find which section is clicked in listview?
如果您指的是 SectionIndexer
,则不会单击部分。
关于android - 在 mergeadapter 中查找 Listview 单击部分适配器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23648374/