警报对话缺少按钮文本

时间:2017-06-25 04:15:34

标签: android android-alertdialog

我有一个应用程序,其中我有用于页面导航的警报对话框。它工作正常所有其他API ...在Android 7.1.1中它正在工作,但没有显示按钮文本。我也尝试使用样式作为这里的答案

Missing buttons on AlertDialog | Android 7.0 (Nexus 5x)

但我解决这个难题并不成功。我的对话java代码如下所示

 private void showGotoPageDialog(){

        if(mTotalPages>0){

            AlertDialog.Builder builder = new AlertDialog.Builder(
                    getActivity(),R.style.AlertDialogTheme);
            builder.setTitle("Quick Navigation To:");
            builder.setSingleChoiceItems(mPageOptions,mPageIndx-1,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,
                                            int item) {
                            mIsDialogDismissed=true;
                            mOptionDiag.dismiss();

                            SlideInDownAnimator animator = new SlideInDownAnimator();
                            animator.setInterpolator(new OvershootInterpolator());
                            animator.setAddDuration(500);
                            animator.setRemoveDuration(500);
                            mQuoteList.setItemAnimator(animator);

                            mPageIndx=item+1;
                            updateQuotesList();
                            updatePageInfo();
                        }
                    });

            builder.setNegativeButton("Dismiss",
                    new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog,
                                            int id) {

                            // action on dialog close
                        }

                    });
            mOptionDiag= builder.create();
            mOptionDiag.show();
        }

    }

我的风格如下

<style name="AppBaseTheme" parent="android:Theme.Light">
		<item name="alertDialogTheme">@style/AlertDialogTheme</item>
    </style>


	<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
		<!-- Customize your theme here. -->
		<item name="colorPrimary">@color/colorPrimary</item>
		<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
		<item name="colorAccent">@color/colorAccent</item>
		<item name="windowActionBar">true</item>
		<item name="alertDialogTheme">@style/AlertDialogTheme</item>
	</style>

	<style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
		<item name="colorPrimary">@color/colorPrimary</item>
		<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
		<item name="colorAccent">@color/colorAccent</item>
		<item name="buttonBarButtonStyle">@style/DialogButtonStyle</item>
	</style>
	<style name="DialogButtonStyle" parent="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog">
		<item name="android:textColor">@color/colorPrimary</item>
	</style>

请检查并告诉我是否有人有类似的问题并解决了。 感谢

0 个答案:

没有答案