Implementation of Android Seekbar drag components

Source: Internet
Author: User

Android Implementation Seekbar Drag components:

Layout: Layout/activity_main.xml

<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Xmlns:tools= "Http://schemas.android.com/tools"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:orientation= "Vertical"
>


<seekbar
Android:id= "@+id/sb1"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:max= "100"
Android:progress= "50"
/>
</LinearLayout>

Java code:

Package com.litsoft.main;


Import android.support.v7.app.ActionBarActivity;
Import Android.os.Bundle;
Import android.os.Process;
Import Android.os.SystemClock;
Import Android.util.Log;
Import Android.view.Menu;
Import Android.view.MenuItem;
Import Android.view.View;
Import Android.view.View.OnClickListener;
Import Android.widget.Button;
Import Android.widget.ProgressBar;
Import Android.widget.SeekBar;
Import Android.widget.SeekBar.OnSeekBarChangeListener;


public class Mainactivity extends actionbaractivity implements onseekbarchangelistener{
Private SeekBar SB1;
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Init ();

}


private void init () {
TODO auto-generated Method Stub
SB1 = (SeekBar) Findviewbyid (R.ID.SB1);
Sb1.setonseekbarchangelistener (this);
}


@Override
public void onprogresschanged (SeekBar SeekBar, int process, Boolean fromuser) {
TODO auto-generated Method Stub
LOG.I ("main", "Progress:" +process);
}


@Override
public void Onstarttrackingtouch (SeekBar arg0) {
TODO auto-generated Method Stub
LOG.I ("main", "Start dragging Seekbar");
}


@Override
public void Onstoptrackingtouch (SeekBar arg0) {
TODO auto-generated Method Stub
LOG.I ("main", "End drag Seekbar");
}





}

Effect:

650) this.width=650; "src=" http://img.blog.csdn.net/20141123144920812 "/>650" this.width=650; "src=" http:// img.blog.csdn.net/20141123144911832 "/>

This article from "Follow the heart of the other side" blog, declined reprint!

Implementation of Android Seekbar drag components

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.