Tôi tạo một mã số AlertDialog
bằng mã bên dưới. Vì lý do nào đó tôi nhận được một nền phụ (xem ảnh) trên Honeycomb và ở trên. Mã số treo phạt cho mọi thứ bên dưới tổ ong. MyCustomDialog
chỉ đơn giản là Theme.Dialog
cho < API-11 và Theme.Holo.Dialog
cho API-11 trở lên.Android Alert Dialog Background Issue API 11+
- Bất kỳ ý tưởng nào về lý do tôi nhận được nền tảng bổ sung?
- Bất kỳ ý tưởng nào tại sao nó bị lỗi cho API < 11? Nó hoạt động tốt nếu tôi loại bỏ các Theme.
Cập nhật tìm câu trả lời cho Câu hỏi # 2. Dường như các nhà xây dựng AlertDialog.Builder(Context context, int theme)
đã được giới thiệu trong API 11. sửa chữa của tôi chỉ đơn giản là thay đổi dòng để:
final AlertDialog.Builder builder = (Integer.parseInt(android.os.Build.VERSION.SDK) < 11)? new AlertDialog.Builder(this) : new AlertDialog.Builder(this,R.style.JumpDialog);
tôi vẫn cần giúp đỡ Câu hỏi # 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;
}
Từ 1.6 trở lên, bạn nên sử dụng Build.VERSION.SDK_INT thay vì vì Build.VERSION.SDK không được dùng nữa. – bCliks
đã cập nhật câu trả lời để xóa api không dùng nữa và mức api được mã hóa cứng – Ali
để "Integer.parseInt" không cần thiết nữa –