Я создаю AlertDialog
с кодом ниже.
По какой-то причине я получаю дополнительный фон (см. Рис.) На Honeycomb и выше.
Код аварийно завершает штраф для чего-либо ниже сотового.
MyCustomDialog
является просто Theme.Dialog
для < API-11 и Theme.Holo.Dialog
для API-11 и выше.
- Любая идея, почему я получаю дополнительный фон?
- Любая идея, почему она сбой для API < 11? Он отлично работает, если я удаляю тему.
Update выяснил ответ на вопрос №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
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;
}