Ali*_*Ali 13 java android android-theme android-dialog
我AlertDialog用下面的代码创建了一个.出于某种原因,我在Honeycomb及以上版本上获得了额外的背景(见图).代码在蜂窝以下的任何地方崩溃都很好.
MyCustomDialog仅Theme.Dialog适用于<API-11和Theme.Holo.DialogAPI-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);
Run Code Online (Sandbox Code Playgroud)
我仍然需要问题#1的帮助

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<Integer>();
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;
}
Run Code Online (Sandbox Code Playgroud)
Ali*_*Ali 17
找出答案
R.style.MyTheme或android.R.style.Theme_Holo_Dialog
使用AlertDialog.THEME_HOLO_LIGHT代码工作得很好.似乎构造函数AlertDialog.Builder(Context context, int
theme)是在API 11中引入的.我的修复只是将行更改为:
final AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
builder = new AlertDialog.Builder(this);
} else {
builder = new AlertDialog.Builder(this,R.style.JumpDialog);
}
Run Code Online (Sandbox Code Playgroud)您可以尝试使用new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.JumpDialog))而不是new AlertDialog.Builder(this, R.style.JumpDialog)
| 归档时间: |
|
| 查看次数: |
6226 次 |
| 最近记录: |