Step by Step _android Development Course [27]_ User Interface Seekbar (drag bar)

Source: Internet
Author: User

Focus on technology, enjoy life! --qq:804212028
Browse Links: http://blog.csdn.net/y18334702058/article/details/44624305

    • Topic: User Interface Seekbar (drag bar)
      -

Seekbar drag Bar (instance):

Activity_main.xml:

<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout  xmlns: Android  = "http://schemas.android.com/apk/res/android"  android:orientation  =" vertical " android:layout_width  = "fill_parent"  android:layout_height  = "fill_parent" ;          <seekbar  android : ID  = "@+id/seek"  android:layout_width= "fill_parent"  android:layout_height  =
     
       "wrap_content" 
      android:max  =" " android:progress  ="  />          <TextViewandroid:id= "@+id/progress"android:layout_width="Fill_ Parent "android:layout_height=" wrap_content " />                                                <TextViewandroid:id="@+id/tracking"android:layout_width=  "Fill_parent"android:layout_height="wrap_content" />                                         </linearlayout>

Mainactivity.java:

Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.widget.SeekBar;ImportAndroid.widget.SeekBar.OnSeekBarChangeListener;ImportAndroid.widget.TextView; Public  class mainactivity extends Activity {SeekBar Mseekbar;        TextView Mprogresstext; TextView Mtrackingtext;@Override         Public void onCreate(Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate); Setcontentview (R.layout.activity_main);//Get Seekbar objectMseekbar = (SeekBar) Findviewbyid (R.id.seek); Mseekbar.setonseekbarchangelistener (NewListener ());                Mprogresstext = (TextView) Findviewbyid (r.id.progress);        Mtrackingtext = (TextView) Findviewbyid (r.id.tracking); } class Listener implements onseekbarchangelistener{ Public void onprogresschanged(SeekBar SeekBar,intProgressBooleanFromuser) {//progress is the size of the current valueMprogresstext.settext ("Current value:"+ progress); }@Override        //This method is called in drag         Public void Onstarttrackingtouch(SeekBar SeekBar) {Mtrackingtext.settext ("Adjusting"); }@Override        //Stop dragging         Public void Onstoptrackingtouch(SeekBar SeekBar) {Mtrackingtext.settext ("Stop Adjustment"); }     }}

Operation Result:

Focus on technology, enjoy life! --qq:804212028
Browse Links: http://blog.csdn.net/y18334702058/article/details/44624305

Step by Step _android Development Course [27]_ User Interface Seekbar (drag bar)

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.