从onItemCheckedStateChanged获取TextView文本

时间:2012-06-16 21:41:13

标签: android listview textview

我正在开发一个Android项目,我正在使用ListView并允许用户长按该项目,以便他们可以在列表视图中选择多个项目。这个位工作正常,但我遇到的问题是找出哪个项目被选中,这样我就可以根据用户选择的内容获取值并对数据库执行查询。下面是我用于检查状态事件的代码,但我无法从这里弄清楚如何从TextView获取值。

    public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked)
    {
        final int checkedCount = getListView().getCheckedItemCount();
        String data = 
        switch (checkedCount)
        {
            case 0:
                mode.setSubtitle(null);
                break;
            case 1:
                mode.setSubtitle("One item selected");
                break;
            default:
                mode.setSubtitle("" + checkedCount + " items selected");
                break;
        }
    }

感谢您提供的任何帮助。

1 个答案:

答案 0 :(得分:1)

 can't figure out from here how to get the value from the TextView.

不确定为什么要从TextView中获取值。因为它是不可编辑的,所以你有项目的正电子,只需从适配器获取此位置的数据,你将得到你在文本视图中设置的位置。

相关问题