android学习——SeekBar和RatingBar

SeekBar 带滑块的进度条 

xml

	<SeekBar 
	android:id="@+id/seekbar" 
	android:layout_width="fill_parent"
	android:layout_height="wrap_content" />


java

class SeekBarListener implements OnSeekBarChangeListener{

		@Override
		public void onProgressChanged(SeekBar seekBar, int progress,
				boolean fromUser) {
			// TODO Auto-generated method stub
			System.out.println("changed");
		}

		@Override
		public void onStartTrackingTouch(SeekBar seekBar) {
			// TODO Auto-generated method stub
			System.out.println("start");
		}

		@Override
		public void onStopTrackingTouch(SeekBar seekBar) {
			// TODO Auto-generated method stub
			System.out.println("stop");
		}
    	
    }



RatingBar 星星评价

xml

	<RatingBar android:stepSize="0.5"  步长
		android:layout_height="wrap_content"
		android:numStars="5"  总长
		android:id="@+id/Ratingbar" 
		android:layout_width="wrap_content"
		android:rating="2" />  默认选中


java

 class RatingBarListener implements RatingBar.OnRatingBarChangeListener{

		@Override
		public void onRatingChanged(RatingBar ratingBar, float rating,
				boolean fromUser) {
			// TODO Auto-generated method stub
			System.out.println(ratingBar.getStepSize());
		}   	
    }



你可能感兴趣的:(java,android,layout,Class,float)