gpt4 book ai didi

java - 如何删除 AlertDialog.Multiple Choice 中的第一个复选标记

转载 作者:行者123 更新时间:2023-12-01 09:48:57 26 4
gpt4 key购买 nike

在某个地方的 AlertDialog 中出现了另一个复选标记 Lollypop!我需要将其删除并留下您自己的。提示,谁能面对?

enter image description here

警报对话框:

mSurchargeBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

boolean[] checkedItems = new boolean[surchargeListNames.length];
int count = surchargeListNames.length;

for (int i = 0; i < count; i++)
checkedItems[i] = selectedSurchargeItems.contains(surchargeListNames[i]);

AlertDialog.Builder builder = new AlertDialog.Builder(DetailsActivity.this, R.style.AlertDialogCustom);
builder.setMultiChoiceItems(surchargeListNames, checkedItems, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
if (isChecked)
selectedSurchargeItems.add(surchargeListNames[which]);
else
selectedSurchargeItems.remove(surchargeListNames[which]);
}
});
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

}
});

AlertDialog dialog = builder.create();
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);

dialog.show();
}

风格:

<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:checkMark">?android:attr/textCheckMark</item>
</style>

最佳答案

您也许可以定义一个扩展 Widget.AppCompat.CompoundButton.CheckBox

的样式

例如

<style name="mycheckbox" parent="Widget.AppCompat.CompoundButton.CheckBox">
<item name="android:button">@null</item>
</style>

并以您的主要风格

<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:checkMark">?android:attr/textCheckMark</item>
<item name="android:checkboxStyle">@style/mycheckbox</item>
</style>

不过我还没有测试过。祝你好运!

关于java - 如何删除 AlertDialog.Multiple Choice 中的第一个复选标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37746383/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com