首先,它運行平穩,但是當我點擊它再次停止如何在AlertDialog中設置動態評級欄視圖?
我在試圖設置動態評分欄視圖AlertDialog
java.lang.IllegalStateException遇到錯誤:指定的孩子已經有家長。您必須先調用子對象的父對象的removeView()。
rtb = LayoutInflater.from(getContext()).inflate(R.layout.ratingbar_dialog, null);
rb = (RatingBar) rtb.findViewById(R.id.rtbDialog);
ad = new AlertDialog.Builder(getContext());
ad.setView(rtb);
ll1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ad.setMessage("Rate Price");
ad.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
ad.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
rtbPrice.setRating(rb.getRating());
}
});
ad.show();
}
});