AlertDialog MultiChoiceItems监听器问题 [英] AlertDialog MultiChoiceItems Listener problems

查看:349
本文介绍了AlertDialog MultiChoiceItems监听器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用的AlertDialog.builder创建multichoice列表中的用户(复选框)。这个伟大的工程,但我们希望其中一个按钮来取消选择列表中的所有其他人。

I am currently using the AlertDialog.builder to create a multichoice list for the user (checkboxes). This works great, except we want one of the buttons to deselect all of the others in the list.

builder.setMultiChoiceItems(list, checked,
  new DialogInterface.OnMultiChoiceClickListener() {
   public void onClick(DialogInterface dialog,
     int item, boolean isChecked) {

    if(item == ANY_ITEM_BUT_0)
    {

     ((AlertDialog) dialog).getListView().setItemChecked(0, false);

    }
   }
  });

在使用真,它将成功地选中该复选框,但使用虚假不取消它时,(除非我有手动设置为true前手。)有,我应该使用,以检测当一个单独的侦听器用户点击这些?在我看来,有两个设置复选标记,一个在setItemChecked(0,真);,以及一个由实际选择它

When using "true" it will successfully check the box, but when using false it does not uncheck it (unless i have manually set it to true before hand.) Is there a separate listener I should be using to detect when a user clicks these? It seems to me that there are two checkmarks set, one by the "setItemChecked(0, true);", and one by actually selecting it.

这是我发疯了几天,现在,任何帮助将大大AP preciated。

This has been driving me nuts for a couple days now, any help would be greatly appreciated.

推荐答案

哦!我忘了,以确保取消则必须更改检查为null;),我有同样的问题。

OH!!! I forget it to ensure deselect you must change checked to null ;), I had the same issue.

    builder.setMultiChoiceItems(list, null, new DialogInterface.OnMultiChoiceClickListener() {
...

这篇关于AlertDialog MultiChoiceItems监听器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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