Rating Example

Rating is important for all developers because he wants to know how the developed work useful for users. Rating has been varied from 1 to 5. We can use simple example for show rating an app.


This class is used to display rating of user.

    package com.example.codebridgeratingexample;  
    import android.os.Bundle;  
    import android.app.Activity;  
    import android.view.Menu;  
    import android.view.View;  
    import android.view.View.OnClickListener;  
    import android.widget.Button;  
    import android.widget.RatingBar;  
    import android.widget.Toast;  
    public class MainActivity extends Activity {  
        RatingBar ratingbar1;  
        Button button;  
        protected void onCreate(Bundle savedInstanceState) {  
        public void addOnButtonClick(){  
            //set Listener on Button Click  
            button.setOnClickListener(new OnClickListener(){  
                public void onClick(View arg0) {  
                    String rating= String.valueOf(ratingbar1.getRating());  
                    Toast.makeText(getApplicationContext(), rating, Toast.LENGTH_LONG).show();  
        public boolean onCreateOptionsMenu(Menu menu) {  
            // Inflate the menu; this adds items to the action bar if it is present.  
            getMenuInflater().inflate(R.menu.activity_main, menu);  
            return true;  


This xml has one rating Bar and button. Its easily drag and drop from pallete of android studio.