从警报对话框更改复选框状态
我的应用程序显示一个列表视图,其中每个项目都有一个复选框和 2 个标签;当用户触摸该复选框时,将弹出一个对话框。该对话框将有一个肯定按钮和一个否定按钮;如果按下否定按钮,我希望复选框返回未选中状态。我尝试轻松地执行此操作(在 onClick 事件上调用复选框),但显然当我进入事件时,我只能从列表视图中读取值,并且无法从主活动中编辑任何小部件状态。 我错过了什么吗?有没有办法从对话框中更改活动的视图?
My app shows a listview, where every item has a checkbox and 2 labels; when the user will touch the checkbox a dialog will pop-up. This dialog will have a positive and a negative button; I'd like the checkbox to return unchecked if the negative button is pressed. I tried doing this easily (calling the Checkbox on the on the onClick event) but apparently when I'm into an event I can only read values from the listview, and I can't edit any widget state from the main activity.
Did I miss something? Is there any way to change an Activity's view from a dialog?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
维护一个全局布尔数组,并根据用户在警报对话框中单击的按钮设置复选框的标志。在按钮的 onclicklisteners 中为列表适配器调用 notificationdatasetchanged()
maintain a global array of boolean and set the flag for the checkbox based on the what button the user clicks in the alert dialog. In the onclicklisteners of the button call notifydatasetchanged() for your list adapter