你如何激活列表活动选中标记? [英] How do you activate checkmarks in list activity?

查看:195
本文介绍了你如何激活列表活动选中标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有像 arrayAdapter =新的ArrayAdapter&LT声明数组适配器ListActivity;字符串> (这一点,android.R.layout.simple_list_item_checked); 这显示了在最右侧选中标记了一堆行。你能告诉我怎么去一提及这些对号或如何检查/取消选中他们?

I have a ListActivity with an array adapter declared like arrayAdapter = new ArrayAdapter<String> (this, android.R.layout.simple_list_item_checked); This shows a bunch of rows with checkmarks on the far right. Can you tell me how to get a reference to those checkmarks or how to check/uncheck them?

推荐答案

该CheckedTextView本身处理的复选框。它会被传递的第二个参数(查看V)在onListItemClick处理。因此,可以简化您的code如下:

The CheckedTextView itself handles the checkbox. It is passed in as the second argument (View v) in the onListItemClick handler. So, you can simplify your code as follows:

@Override
protected void onListItemClick( ListView l, View v, int position, long id)
{
  CheckedTextView textView = (CheckedTextView)v;
  textView.setChecked(!textView.isChecked());
}

这篇关于你如何激活列表活动选中标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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