Android ApiDemos example resolution (191): Views-& gt; Seek Bar

Source: Internet
Author: User

SeekBar is a child of ProgressBar. Unlike ProgressBar, SeekBar adds a slide that can be dragged. You can move the slider left and right to set the current value for SeekBar, therefore, it is best not to place other controls that can obtain the focus around the SeekBar.

This example introduces the basic usage of SeekBar and the supported event SeekBar. OnSeekBarChangeListener.


[Java]
Public void onProgressChanged (SeekBar seekBar,
Int progress, boolean fromTouch ){
MProgressText. setText (progress + "" +
GetString (R. string. seekbar_from_touch)
+ "=" + FromTouch );
}
 
Public void onStartTrackingTouch (SeekBar seekBar ){
MTrackingText
. SetText (getString (R. string. seekbar_tracking_on ));
}
 
Public void onStopTrackingTouch (SeekBar seekBar ){
MTrackingText
. SetText (getString (R. string. seekbar_tracking_off ));
}

Public void onProgressChanged (SeekBar seekBar,
Int progress, boolean fromTouch ){
MProgressText. setText (progress + "" +
GetString (R. string. seekbar_from_touch)
+ "=" + FromTouch );
}

Public void onStartTrackingTouch (SeekBar seekBar ){
MTrackingText
. SetText (getString (R. string. seekbar_tracking_on ));
}

Public void onStopTrackingTouch (SeekBar seekBar ){
MTrackingText
. SetText (getString (R. string. seekbar_tracking_off ));
}

You can also set android: secondaryProgress in SeekBar. Drag the slider to change the value of the main Progresss.

 

[Html]
<SeekBar android: id = "@ + id/seek"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: max = "100 ″
Android: progress = "50 ″
Android: secondaryProgress = "75"/>

<SeekBar android: id = "@ + id/seek"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: max = "100 ″
Android: progress = "50 ″
Android: secondaryProgress = "75"/>

 


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.