0
我在這我想傳遞一個浮動的對話框,如下所示:如何將值傳遞給android對話框?
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
}
這實際上是可能的,如果是怎樣?
如何使用DialogFragment?你的目標是低於API 11嗎? –