Control Seekbar progress bar to trigger ProgressBar at the same time

Source: Internet
Author: User

1 <?XML version= "1.0" encoding= "Utf-8"?>2 <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"3 Xmlns:tools= "Http://schemas.android.com/tools"4 Android:layout_width= "Match_parent"5 Android:layout_height= "Match_parent"6 Android:paddingbottom= "16DP"7 Android:paddingleft= "16DP"8 Android:paddingright= "16DP"9 Android:paddingtop= "16DP"Ten Tools:context= "Com.example.wang.testapp2.TestActivity4" One android:orientation= "vertical"> A  -     <ProgressBar -         Android:layout_width= "Match_parent" the Android:layout_height= "Wrap_content" - style= "? Android:attr/progressbarstylehorizontal" - android:progress= "Max" - android:secondaryprogress= " the" + Android:max= "a" - Android:id= "@+id/pb_1"/> +  A     <ProgressBar at         Android:layout_width= "Match_parent" - Android:layout_height= "Wrap_content" - style= "? Android:attr/progressbarstylelarge" - Android:id= "@+id/pb_2"/> -  -     <SeekBar in         Android:layout_width= "Match_parent" - Android:layout_height= "Wrap_content" to android:progress= "Max" + Android:max= "a" - android:secondaryprogress= " the" the Android:id= "@+id/se_1"/> *  $ </LinearLayout>
. XML
1  Packagecom.example.wang.testapp2;2 3 Importandroid.app.Activity;4 ImportAndroid.app.AlertDialog;5 Importandroid.support.v7.app.AppCompatActivity;6 ImportAndroid.os.Bundle;7 ImportAndroid.util.Log;8 ImportAndroid.view.View;9 ImportAndroid.widget.ImageView;Ten ImportAndroid.widget.ProgressBar; One ImportAndroid.widget.SeekBar; A ImportAndroid.widget.Toast; -  -  Public classTestActivity4extendsActivity { the  - ProgressBar pb_1; - ProgressBar pb_2; - SeekBar se_1; +      - @Override +     protected voidonCreate (Bundle savedinstancestate) { A         Super. OnCreate (savedinstancestate); at Setcontentview (R.LAYOUT.ACTIVITY_TEST4); -  -se_1=(SeekBar) Findviewbyid (r.id.se_1); -pb_1=(ProgressBar) Findviewbyid (r.id.pb_1); -Pb_2=(ProgressBar) Findviewbyid (r.id.pb_2); -  inSe_1.setonseekbarchangelistener (NewSeekbar.onseekbarchangelistener () { -  to             //Progress Change Trigger + @Override -              Public voidOnprogresschanged (SeekBar SeekBar,intProgressBooleanFromuser) { the  *                 //set progress value for progress bar 1 $ pb_1.setprogress (progress);Panax Notoginseng  -  the                 //determine if the maximum value is reached +                 if(Progress = =Se_1.getmax ()) A                 { thePb_2.setvisibility (view.invisible);//not displayed but the location is still reserved +                 } -                 Else $                 { $ pb_2.setvisibility (view.visible); -                 } -  the                 //as long as the progress change is triggered . - Wuyi //Toast.maketext (Testactivity4.this, "current progress =" +progress, Toast.length_short). Show (); the             } -  Wu @Override -              Public voidOnstarttrackingtouch (SeekBar SeekBar) { About  $LOG.E ("TAG", "progress bar start dragging"); -             } -  - @Override A              Public voidOnstoptrackingtouch (SeekBar SeekBar) { +  theLOG.E ("TAG", "Progress bar Stop dragging"); -  $             } the         }); the  the     } the}
. Java

Control Seekbar progress bar to trigger ProgressBar at the same time

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.