拖动条

作者: suxiliu | 来源:发表于2016-09-10 01:39 被阅读3次
    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="当前值:50" />
    <SeekBar
        android:max="100"
        android:progress="50"
        android:padding="10dp"
        android:id="@+id/seekBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    
    public class MainActivity extends AppCompatActivity {
        private RatingBar ratingBar;
        private Button bn;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            ratingBar = (RatingBar) findViewById(R.id.ratingBar);
            bn = (Button) findViewById(R.id.bn);
            bn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    int result = ratingBar.getProgress();
                    float raing = ratingBar.getRating();
                    float step = ratingBar.getStepSize(); 
                   Log.i("星级评分","'进度值:"+result+"默认星:"+raing+"每一步多少:"+step);
                   Toast.makeText(MainActivity.this, "您获得了"+raing+"颗星星",Toast.LENGTH_SHORT).show();
                }
            });
        }
    }
    

    相关文章

      网友评论

          本文标题:拖动条

          本文链接:https://www.haomeiwen.com/subject/hqdyettx.html