Android-Drag bar (SeekBar) instance

Source: Internet
Author: User

The Main.xml code is as follows:

<?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:o rientation= "vertical" >    <seekbar        android:id= "@+id/seekbar"        android:layout_width= "Fill_parent"        android:layout_height= "wrap_content"/>    <textview        android:id= "@+id/text"        android:layout_ Width= "Fill_parent"        android:layout_height= "wrap_content"        android:scrollbars= "vertical"/></ Linearlayout>

. Java code is as follows:

Package Org.lxh.demo;import Android.app.activity;import Android.app.alertdialog;import android.app.Dialog;import Android.app.progressdialog;import Android.content.dialoginterface;import Android.os.bundle;import Android.text.method.scrollingmovementmethod;import Android.view.layoutinflater;import Android.view.View;import Android.view.view.onclicklistener;import Android.widget.adapterview;import Android.widget.adapterview.onitemclicklistener;import Android.widget.adapterview.onitemselectedlistener;import Android.widget.button;import Android.widget.seekbar;import Android.widget.seekbar.onseekbarchangelistener;import Android.widget.spinner;import Android.widget.textview;public class Hello extends Activity {private SeekBar seek = null; Private TextView Text = null, @Overridepublic void OnCreate (Bundle savedinstancestate) {super.oncreate ( Savedinstancestate); Life cycle Method Super.setcontentview (R.layout.main); Set the layout manager to use This.seek = (SeekBar) Super.findviewbyid (r.id.seekbar); this.text = (TextView) Super.findviewbyid (R.id.text); This.text.setMovementMethod (Scrollingmovementmethod.getinstance ()); This.seek.setOnSeekBarChangeListener (New Onseekbarchangelistenerimpl ());} Private class Onseekbarchangelistenerimpl Implementsonseekbarchangelistener {public void onprogresschanged (SeekBar SeekBar, int progress,boolean fromuser) {Hello.this.text.append ("* * * is dragging, current value is:" + seekbar.getprogress () + "\ n");} public void Onstarttrackingtouch (SeekBar SeekBar) {text.append ("Start dragging, current value:" + seekbar.getprogress () + "\ n");} public void Onstoptrackingtouch (SeekBar SeekBar) {text.append ("* * * stop dragging, current value:" + seekbar.getprogress () + "\ n");}}}

The results are as follows:


SOURCE Download: http://download.csdn.net/detail/yayun0516/8379373


Android-Drag bar (SeekBar) instance

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.