如何检查列表项被选中与否列表视图android的? [英] how to check listitem is checked or not in listview android?

查看:107
本文介绍了如何检查列表项被选中与否列表视图android的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有列表视图是选择题模式

i have listview which is multiple choice mode

lView = (ListView) findViewById(R.id.ListView01);
lView.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_multiple_choice, lv_items));
lView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

这包含了多项选择列表项 我要检查是否选择的项目被选中或不 所以我怎么能做到这一点。

this contains multiple choice list items i want to check whether selected item is checked or not so how i can do that.

推荐答案

我用的是定列表项的财产器isChecked点击时:

I used the isChecked property of the given list item when clicked:

protected void onListItemClick(ListView l, View v, int position, long id) {
    CheckedTextView item = (CheckedTextView)v;
    if(item.isChecked()){
            //do what you want
    }

这篇关于如何检查列表项被选中与否列表视图android的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆