我使用了阶梯式评级对话框。我想在有条件的情况下将正或负按钮设置为禁用

时间:2018-06-26 12:55:57

标签: android

这基本上是我为我的评分而编译的一个stepstone ratingDialog。如果不满足某些条件,我想禁用中性或否定按钮,例如setEnabled false。如何设置按钮正或负setEnabled false?

private void showRatingDialog() {
 new AppRatingDialog.Builder()
            .setPositiveButtonText("Submit")
            .setNegativeButtonText("Cancel")
            .setNeutralButtonText("Upload Image")
            .setNoteDescriptions(Arrays.asList("Not Satisfied","Not Bad","Normal Place","Good Place","Must Visit"))
            .setTitle("Rate this location")
            .setDescription("Please give some rating and  feedback")
            .setDefaultRating(1)
            .setStarColor(R.color.colorPrimary)
            .setNoteDescriptionTextColor(R.color.colorPrimary)
            .setTitleTextColor(R.color.colorAccent)
            .setDescriptionTextColor(R.color.colorAccent)
            .setHint("Please write your comment here ")
            .setHintTextColor(R.color.colorPrimary)
            .setCommentTextColor(R.color.colorPrimary)
            .setCommentBackgroundColor(R.color.colorPrimaryDark)
            .setWindowAnimation(R.style.MyDialogFadeAnimation)
            .create(LocationDetails.this)
            .show();


}


 @Override
public void onNegativeButtonClicked() {


}

1 个答案:

答案 0 :(得分:0)

看着jpp solution,它具有设置按钮的条件。

private fun setupNeutralButton(builder: AlertDialog.Builder) {
    if (!TextUtils.isEmpty(neutralButtonText)) {
        builder.setNeutralButton(neutralButtonText) { dialog, which ->
            listener?.onNeutralButtonClicked()
        }
    }
}

尝试.setNeutralButtonText("")