alertdialog android api 11,Android警报对话框背景问题API 11+

我AlertDialog用下面的代码创建了一个.出于某种原因,我在Honeycomb及以上版本上获得了额外的背景(见图).代码在蜂窝以下的任何地方崩溃都很好.

MyCustomDialog仅Theme.Dialog适用于

知道为什么我得到额外的背景吗?

知道为什么它崩溃API <11?如果我删除主题,它工作正常.

更新找到了问题#2的答案.似乎构造函数AlertDialog.Builder(Context context, int theme)是在API 11中引入的.我的修复只是将行更改为:

final AlertDialog.Builder builder = (Integer.parseInt(android.os.Build.VERSION.SDK) < 11)? new AlertDialog.Builder(this) : new AlertDialog.Builder(this,R.style.JumpDialog);

我仍然需要问题#1的帮助

170d8175698d1f491563e41d061b6878.png

private Dialog setupKeyBoardDialog() {

if (mContact.getLocaleId() != -1) {

final AlertDialog.Builder builder = new AlertDialog.Builder(this,R.style.MyCustomDialog);

builder.setTitle("Keyboards");

mKeyboardLayouts = new KeyboardLayoutGroup();

mKeyboardLayouts.layoutNames = new CharSequence[(int) jni.getNumKeyLayouts()];

mKeyboardLayouts.layoutValue = new ArrayList();

for (int i = 0; i < jni.getNumKeyLayouts(); i++) {

mKeyboardLayouts.layoutNames[i] = jni.LayoutInfoForIndex(i).getName();

mKeyboardLayouts.layoutValue.add(i, (int) jni.LayoutInfoForIndex(i).getLocale_id());

}

final int selectedItem = mKeyboardLayouts.layoutValue.indexOf(mContact.getLocaleId());

builder.setSingleChoiceItems(mKeyboardLayouts.layoutNames, selectedItem, new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int item) {

mContact.setLocaleId(mKeyboardLayouts.layoutValue.get(item));

mContactsDB.saveContact(mContact, true);

dialog.dismiss();

initializeSettingsList();

}

});

final AlertDialog dialog = builder.create();

dialog.setButton("Cancel", new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialogBox, int arg1) {

dialogBox.cancel();

}

});

return dialog;

}

return null;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值