- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在更改警报对话框的复选框主题时遇到问题。我无法将选中的复选框颜色更改为我的 AccentColor。
这是我的样式代码
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:checkboxStyle">@style/CustomCheckBox</item>
</style>
<style name="CustomCheckBox" parent="android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/activated_checkbox</item>
</style>
选择器:activated_checkbox
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- checked -->
<item android:state_checked="true" android:drawable="@color/AccentColor">
</item>
<item android:state_checked="false" android:drawable="@color/White">
</item>
</selector>
以及显示 AlertDialog 的方法。
private void showDialog() {
final CharSequence[] items = getResources().getStringArray(R.array.tipoDescargas);
final boolean[] states = {false, false, false};
AlertDialog.Builder builder = new AlertDialog.Builder(this,R.style.AlertDialogCustom);
builder.setTitle(getResources().getString(R.string.preguntaDescargas));
builder.setMultiChoiceItems(items, states, new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialogInterface, int item, boolean state) {
}
});
builder.setPositiveButton("Descargar", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
SparseBooleanArray CheCked = ((AlertDialog) dialog).getListView().getCheckedItemPositions();
if (CheCked.get(0) && CheCked.get(1) && CheCked.get(2))
Toast.makeText(getApplication(), "TODOS", Toast.LENGTH_SHORT).show();
if (CheCked.get(0)) {
Toast.makeText(getApplication(), "Item 1", Toast.LENGTH_SHORT).show();
}
if (CheCked.get(1)) {
Toast.makeText(getApplication(), "Item 2", Toast.LENGTH_SHORT).show();
}
if (CheCked.get(2)) {
Toast.makeText(getApplication(), "Item 3", Toast.LENGTH_SHORT).show();
}
}
});
builder.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});builder.create().show();
}
谁能帮帮我?谢谢
更新 1
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:checkedTextViewStyle">@style/CustomCheckBox</item>
</style>
<style name="CustomCheckBox" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:checkMark">@drawable/activated_checkbox</item>
</style>
解决方案
我找到了正确显示颜色的解决方案。
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:listChoiceIndicatorMultiple">@drawable/activated_checkbox</item>
</style>
和选择器
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/checkedcheckbox24" android:state_checked="true"></item>
<item android:drawable="@drawable/uncheckedcheckbox24" android:state_checked="false"></item>
</selector>
最佳答案
使用这段代码,图标可以正确显示
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:listChoiceIndicatorMultiple">@drawable/activated_checkbox</item>
</style>
和选择器代码
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/checkedcheckbox24" android:state_checked="true"></item>
<item android:drawable="@drawable/uncheckedcheckbox24" android:state_checked="false"></item>
</selector>
关于android - 在 Android 的 AlertDialog 中更改 CheckBox 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32761557/
在检查复选框时我发现有写 CheckBox checkbox = (CheckBox)sender 在 checkBox1_CheckedChanged 事件上。 请解释一下这是什么意思? 最佳答案
我正在使用来自命名空间 System.Windows.Forms 的 ToolTip 类编辑我的 Web 应用程序;我的代码中有几个复选框,因此显示此错误: 'CheckBox' is an ambi
我正在制作 Bootstrap 复选框下拉菜单,选项包含在 中。处理点击的标签,但我也有一个 在 a 标签内。 当用户按下实际复选框而不是仅按下 时,就会出现我的问题。元素。两者都被点击并且发生了
TLDR:使用defaultChecked而不是checked,工作jsbin . 尝试设置一个简单的复选框,在选中时会划掉其标签文本。由于某种原因,当我使用该组件时,handleChange 没有被
我想拥有它,所以如果复选框为 NULL 或 0,则它不像值为 1 时那样喜欢。另外,有没有办法将选中的框限制为 10 个? 当前代码: if(isset($_POST['submit'])){//to
如果我选中一个复选框,下拉列表应该只显示在该复选框旁边,但它会显示在它下面的所有其他复选框中。 这是我在 html 代码中使用的 css .sub-nav { display: none; } inp
我在警报对话框中有一个带有复选框的数据表,当我单击该复选框时,它没有选中(选中=选中)该框。我跟着这个video 这是我的尝试 import 'package:flutter/material.dar
如果单独使用,以下代码效果很好, Angular6.0 不允许 [(ngModel)] 与 FormGroup (Reactive Forms)。 As 在 angular 6.0 中已弃用,并将在
那么我应该使用哪个来选择元素?我仅使用复选框作为示例,这个问题涉及所有表单元素。 实际上,当我们这样做时,哪个更快: li:first 或 li:eq(0) ? 最佳答案 来自the document
问题 : 我有一个列表框,其中列表框是复选框。在第一次单击时,复选框被选中并选中。在第二次单击时,仅设置复选框。可以使用箭头键重新选择不同的复选框。我的目标是,首先选中该复选框,然后再检查(再次单击它
我似乎无法弄清楚如何让复选框和相关文本出现在一行上。文本很短,所以它似乎不是宽度问题。 我尝试在控件上设置 display:inline,但是当它呈现时,在输入和标签周围添加了一个跨度,并且具有 di
创建带有复选框列的 Table 非常容易,例如,使用 SWT.CHECK 标志。但是如何使某些表格行中的复选框不可编辑而其他行中的复选框保持可编辑? 最佳答案 我不知道这样做的简单方法。 但我看到了两
是否可以使用 TogglerBar 而不是 2 个复选框来显示或不显示不同的形状。 TogglerBar 的每个按钮中都写有绿色和红色? Manipulate[ Graphics[{If[thePin
我需要更改 Windows Phone 8 中 LongListMultiSelector 的复选框的颜色,因为我的背景是白色,这可能吗? 谢谢。 最佳答案 为此,您必须首先通过在 visual st
我有一个带有插件 Slick.CheckboxSelectColumn 的网格。 是否可以在没有 Jquery 的情况下隐藏某些行中的复选框?我想可以使用 Formatter。 这是带有 slickg
所以我有这个... 在这里,id 是有道理的值在引号中,因为它是一个字符串标识符。但是type呢?值(value)?不是 checkbox一种类型,例如 String 和 Boolean?为什么我总
问题: 如果用户选中了复选框,我将尝试验证下拉列表,如您在屏幕一中所见。 问题: 那么,如果用户选择了标题中的所有复选框,我该如何验证复选框呢?如您所见,屏幕二。如果我选中所有复选框,那么我希望启动验
我知道它有点重复,我正在尝试以不同的方式做到这一点,从而重新发布这个问题。 我想要实现的是,当有人“取消选中”OSPF 复选框时..被动接口(interface)检查也应该自动“取消选中”。我正在尝试
这是代码(是的,我使用的是基本的 reset.css): .checkbox { border: 1px solid black; width: 10px; height: 10px; }
我正在尝试显示多组带有标题复选框的复选框,如下图所示。 从数据库中我得到这样的数据, CODE SUBCODE DESCR DESCR
我是一名优秀的程序员,十分优秀!