我用AlertDialog提醒用戶確認刪除。我檢查我的設備(Android的5.1),並將其呈現非常對話框不顯示正負按鈕
但在某些其他設備(也運行Android 5.1),對話框錯過了正面和負面的按鈕。
我查了一下,發現設備出現這個問題有一箇中等分辨率(960×540,854×480)。
分辨率是否與此問題有關? 如果不是,你能告訴我原因以及如何解決這個問題嗎?
我顯示的對話框代碼:
public static final Dialog yesNoDialog(Context context,
String message,
DialogInterface.OnClickListener yesAction, DialogInterface.OnClickListener noAction) {
AlertDialog.Builder builder = new AlertDialog.Builder(context,R.style.todoDialogLight);
builder.setTitle(context.getString(R.string.app_name))
.setMessage(message)
.setCancelable(false)
.setPositiveButton("YES", yesAction)
.setNegativeButton("NO", noAction);
return builder.create();
}
而styles.xml
<style name="todoDialogLight" parent="Theme.AppCompat.Light.Dialog">
<!-- Used for the buttons -->
<item name="colorAccent">@color/colorPrimaryDark</item>
<item name="android:textStyle">bold</item>
<!-- Used for the title and text -->
<item name="android:textColorPrimary">@color/colorText</item>
<!-- Used for the background -->
<!-- <item name="android:background">#4CAF50</item>-->
<item name="android:fontFamily">sans-serif</item>
<item name="android:windowAnimationStyle">@style/RemindDialogAnimation</item>
<item name="android:layout_width">@dimen/width_remind_dialog</item>
<item name="android:layout_height">wrap_content</item>
</style>
這是怎麼一回事? PreferenceUtil在哪裏?樣式「todoDialogLight」和「todoDialogDark」在哪裏?請改進您的回答 – usman