Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问QMUIDialog单项选择时怎么让选中某项的时候,该项选中?显示“√”呢?不是默认选择某项 #200

Closed
4 tasks done
DeveloperHu opened this issue Mar 9, 2018 · 10 comments

Comments

@DeveloperHu
Copy link

DeveloperHu commented Mar 9, 2018

运行环境

  • 设备型号:如:小米5X
  • 设备系统版本:如 Android 7.0
  • Gradle 版本:如 4.1
  • QMUI Android 版本:1.x.x

具体问题描述

请问QMUIDialog单项选择时怎么让选中某项的时候,该项选中?显示“√”呢?不是默认选择某项

问题截图

异常日志(堆栈)

@cgspine
Copy link
Collaborator

cgspine commented Mar 9, 2018

你是想不通过点击而选中某项?如果是这样,你可以写一个类继承 CheckableDialogBuilder,通过
mMenuItemViews.get(mCheckedIndex).setChecked(true); 来更新。目前 mMenuItemViews 是 protect 的,因此你还是可以拿到所有的子 view

@DeveloperHu
Copy link
Author

不是的,像QMUIDialog中的单项菜单类型对话框有有三个选项,我想点击某一项的时候,该项的后面就有一个“√”。
final QMUIDialog.CheckableDialogBuilder builder = new QMUIDialog.CheckableDialogBuilder(this);
// builder.setCheckedIndex(checkedIndex);
builder .addItems(items, new DialogInterface.OnClickListener() {
@OverRide
public void onClick(DialogInterface dialog, int which) {
builder.setCheckedIndex(which);
}
});

我发现这样并不能达到我要的效果,请问应该怎么做?

@DeveloperHu
Copy link
Author

DeveloperHu commented Mar 9, 2018

@cgspine 请问这个如何实现呢?
还有如何修改对话框按钮的颜色呢?

@cgspine
Copy link
Collaborator

cgspine commented Mar 9, 2018

MultiCheckableDialogBuilder 的效果,但是图标换成“√” ?
换图标可以在 theme 中改:@drawable/qmui_s_dialog_check_mark

@cgspine
Copy link
Collaborator

cgspine commented Mar 9, 2018

<item name="qmui_s_checkbox">@drawable/qmui_s_dialog_check_mark</item>

@DeveloperHu
Copy link
Author

DeveloperHu commented Mar 9, 2018

就是说在CheckableDialogBuilder 不能点击某项后,某项后面打“√”吗?只有在MultiCheckableDialogBuilder 才能?
你可以看一下demo中的单项菜单类型对话框,当点击里面某项的时候,后面没有打“√”。我想让他点击后,显示打“√”。builder.setCheckedIndex(该项的index);这个怎么没有用?
@cgspine

@cgspine
Copy link
Collaborator

cgspine commented Mar 9, 2018

我懂了,目前好像“√”显示不出来了,应该是出 bug 了, 我看一下

@cgspine
Copy link
Collaborator

cgspine commented Mar 9, 2018

发布了 1.0.8 版本

@DeveloperHu
Copy link
Author

DeveloperHu commented Mar 12, 2018

好的 非常感谢。
还有请问如何修改对话框中按钮的颜色呢?

@cgspine
Copy link
Collaborator

cgspine commented Mar 12, 2018

主题中使用 qmui_dialog_action_text_color 进行按钮颜色配置。 不过修改方式 1.1 版本会改,之后会提供升级说明,需要留意

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants