Friday, December 3, 2010

How to post rating

myRating = new RatingBar(this);  //Create a rating bar.
myRating_Label = new TextView(this);  //Create a label;
  
myRatingView = new LinearLayout(this);  //Create a LinearLayout
myRatingView.setOrientation( LinearLayout.VERTICAL );

myRatingView.addView(myRating_Label);  //Add the label to the View
myRatingView.addView(myRating);  //Add rating bar to the View
  
alert = new AlertDialog.Builder(this).create(); //Create a AlertDialog

alert.setView(myRatingView);  //Add the Rating View to the alert

  // Add a button to the Alert
alert.setButton("Submit", new DialogInterface.OnClickListener() {
   public void onClick(DialogInterface dialog, int whichButton) {
    String value = "Thanks for your rating " + String.valueOf(User_Rating);
    Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show();

   }
});

No comments:

Post a Comment