1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AndroidでRatingBarを表示する

Posted at
activity_main.xml
    <RatingBar
        android:id="@+id/rating"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:numStars="6"
        android:rating="4"
        android:stepSize="0.5"
        />
MainActivity.java
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        RatingBar rate = (RatingBar) findViewById(R.id.rating);
        rate.setOnRatingBarChangeListener(
            new RatingBar.OnRatingBarChangeListener(){
                public void onRatingChanged(
                        RatingBar ratingBar,
                        float rating,
                        boolean fromUser){
                    Toast.makeText(
                            MainActivity.this,
                            String.format("現在の評価は%f", rating),
                            Toast.LENGTH_SHORT).show();
                }
            }
        );
    }
    
}

スクリーンショット 2017-01-02 22.10.33.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?