Android---The use of---progressbar progress bar

Source: Internet
Author: User






Activity_main.xml:


<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" fill_parent "android:layout_height=" Fill_parent "Android:orienta tion= "vertical" android:paddingbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_ Horizontal_margin "android:paddingright=" @dimen/activity_horizontal_margin "android:paddingtop=" @dimen/activity_ Vertical_margin "tools:context=" com.example.progressbardemo.MainActivity "> <textview android:layout_wi        Dth= "Wrap_content" android:layout_height= "wrap_content" android:text= "Small round progress bar"/> <progressbar Style= "@android: Attr/progressbarstylesmalltitle" android:layout_width= "Wrap_content" android:layout_height = "Wrap_content"/> <textview android:layout_width= "wrap_content" android:layout_height= "Wrap_conten T "android:text=" Medium round progress bar "/> <progressbar       Android:layout_width= "Wrap_content" android:layout_height= "wrap_content"/> <textview androi D:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:text= "Large circular progress bar"/> <Progr Essbar style= "@android: Style/widget.progressbar.large" android:layout_width= "Wrap_content" Android:la yout_height= "Wrap_content"/> <textview android:layout_width= "wrap_content" android:layout_height= " Wrap_content "android:text=" Horizontal progress bar "/> <progressbar style=" @android: Style/widget.progressbar.horizon        Tal "Android:layout_width=" fill_parent "android:layout_height=" wrap_content "android:max=" 100 " android:progress= "/> <progressbar android:id=" @+id/bar "style=" @android: STYLE/WIDGET.PROGRESSB Ar. Horizontal "android:layout_width=" Fill_parent "android:layout_height=" Wrap_content "Android:layout_ma       rgintop= "20DP" android:max= "android:progress=" "android:secondaryprogress="/> <linearlayout and        Roid:layout_width= "Fill_parent" android:layout_height= "fill_parent" android:orientation= "Horizontal" > <button android:id= "@+id/button1" android:layout_width= "Wrap_content" Android:lay out_height= "Wrap_content" android:layout_margintop= "20DP" android:text= "Increase progress"/> <butto n android:id= "@+id/button2" android:layout_width= "wrap_content" android:layout_height= "WR Ap_content "android:layout_margintop=" 20DP "android:text=" reduce progress "/> </linearlayout></l Inearlayout>



Maina.java:


Import Android.app.activity;import android.os.bundle;import Android.os.handler;import Android.view.Menu;import Android.view.menuitem;import Android.view.view;import Android.view.view.onclicklistener;import Android.view.window;import Android.widget.button;import Android.widget.progressbar;public class MainActivity Extends Activity implements Onclicklistener {private ProgressBar progressbar;private button button, button2;@ overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);// How to set the effect of a window with a scale requestwindowfeature (window.feature_progress); Requestwindowfeature (Window.feature_indeterminate_ PROGRESS); Setcontentview (r.layout.activity_main);p Rogressbar = (progressBar) Findviewbyid (R.id.bar); Setprogressbarvisibility (True); Setprogressbarindeterminate (true); setprogress (3500); button = (Button) Findviewbyid (r.id.button1); button2 = (Button) Findviewbyid (R.id.button2); Button.setonclicklistener (this); Button2.setonclicklistener (this);} @Overridepublic void OnClick (VIew v) {//TODO auto-generated method Stubswitch (V.getid ()) {case r.id.button1:progressbar.setprogress ((int) ( Progressbar.getprogress () * 1.2));p rogressbar.setsecondaryprogress ((int) (progressbar.getsecondaryprogress () * 1.2) ); Break;case r.id.button2:progressbar.setprogress ((int) (progressbar.getprogress () * 0.8)); Progressbar.setsecondaryprogress ((int) (progressbar.getsecondaryprogress () * 0.8)); break;default:break;}}}



Android---The use of---progressbar progress 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.