android--Drag Bar Seekbar

Source: Internet
Author: User

1, Activity_seekbar.xml

<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
android:orientation= "Vertical" >

<seekbar
Android:id= "@+id/sb"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:max= "
android:progress= "
android:secondaryprogress= " the"/>

<textview
Android:id= "@+id/progresstext"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"/>

<textview
Android:id= "@+id/trackingtext"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"/>

</LinearLayout>

2, Seekbaractivity.java

public class Seekbaractivity extends Activity implements
Onseekbarchangelistener {
Declaring a related View object
Private SeekBar SB;
Private TextView Progresstext, Trackingtext;

@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_seekbar);
Get View related objects
SB = (SeekBar) Findviewbyid (R.ID.SB);
Progresstext = (TextView) Findviewbyid (R.id.progresstext);
Trackingtext = (TextView) Findviewbyid (R.id.trackingtext);
// *************
Sb.setonseekbarchangelistener (this);

}

In drag, the value is changing
@Override
public void onprogresschanged (SeekBar SeekBar, intProgress,
Boolean Fromtouch) {
Progresstext.settext ("Current value is:" + progress);
}

@Override
public void Onstarttrackingtouch (SeekBar arg0) {
Trackingtext.settext ("Adjusting! ");
}

@Override
public void Onstoptrackingtouch (SeekBar arg0) {
Trackingtext.settext ("Stop Adjustment");
}

}

android--Drag Bar Seekbar

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.