我有一个对话框,我试图在其中传递一个浮点数,如下所示:
public void rateDialog(View v){
// custom dialog
AlertDialog.Builder builder = new AlertDialog.Builder(this);
// Add the buttons
builder.setPositiveButton("save", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User clicked OK button
}
});
builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
}
});
// Set other dialog properties
// Create the AlertDialog
builder.setTitle("Rate this Beer");
builder.setView(getLayoutInflater().inflate(R.layout.rate_stars, null));
AlertDialog dialog = builder.create();
RatingBar ratingBar = (RatingBar) this.findViewById(R.id.beerRatingBar);
float stars = ratingBar.getRating();
dialog.show(stars);
// Create the AlertDialog
}
这实际上可能吗?如果可以,怎么办?