Android List dialog box and progress Dialog

Source: Internet
Author: User
Tags xmlns


<linearlayout xmlns:android= ""
    xmlns:tools= "http:// "
    android:layout_width=" fill_parent "
    android:layout_height=" Fill_parent
    " Android:gravity= "Center_horizontal"
    android:orientation= "vertical"

        android:id= "@+id/listdialogbutton"
        android:layout_width= "wrap_content"
        android:layout_height= "Wrap_content"
        android:text= "@string/listdialog_button" 
        android:layout_margintop= "100dip"
        android:textsize= " 20sp "
        android:id=" @+id/progressdialogbutton "
        android:layout_width=" Wrap_ Content "
        android:layout_height=" wrap_content "
        android:text=" "@string/progressdialog_button 
        " android:layout_margintop= "100dip"
        android:textsize= "20sp"



Import Android.content.DialogInterface;
Import Android.os.Bundle;
Import Android.view.View;
Import Android.view.View.OnClickListener;
Import Android.widget.Button;
Import Android.widget.Toast;
    public class Mainactivity extends activity {private Button Mlistbutton;
    Private Button Mprogressbutton;
    Private Dialog Mlistdialog;
    Private ProgressDialog Mprogressdialog;
    private int currentprogress=0;
	private int maxprogress=100;
		@Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);
		Setcontentview (R.layout.main);
	Init ();
    	private void Init () {mlistbutton= (Button) Findviewbyid (;
    	Mlistbutton.setonclicklistener (New Buttononclicklistenerimpl ());
    	mprogressbutton= (Button) Findviewbyid (; Mprogressbutton.setonclicklistener(New Buttononclicklistenerimpl ());
			Private class Buttononclicklistenerimpl implements Onclicklistener {@Override public void OnClick (view view) { Switch (View.getid ()) {case listbuilder=new Builder (mainactivity.this)
                Listbuilder.seticon (R.drawable.ic_launcher);
                Listbuilder.settitle (Getresources (). getString (R.string.list_dialog_title)); Listbuilder.setitems (Getresources (). Getstringarray (R.array.listdialogarray), new Dialoginterface.onclicklistener () {@Override public void OnClick (Dialoginterface dialog, int which) {String selected=getresources (). Get
						Stringarray (R.array.listdialogarray) [which];
					Toast.maketext (mainactivity.this,selected, Toast.length_short). Show ();
                Mlistdialog=listbuilder.create ();
			Break Case ProgresSdialog (Mainactivity.this);
				Mprogressdialog.setmax (maxprogress);  
				Mprogressdialog.setprogressstyle (progressdialog.style_horizontal);
				Mprogressdialog.settitle (R.string.progress_dialog_title);
				Mprogressdialog.seticon (R.drawable.ic_launcher);
				Mprogressdialog.setmessage (Getresources (). getString (R.string.progress_dialog_message));
                Mprogressdialog.setcancelable (FALSE);
       (); New Thread () {public void run () {try {Currentprogress&lt;=ma
                    			xprogress) {mprogressdialog.setprogress (currentprogress++);
                    		Thread.Sleep (500);
						} mprogressdialog.cancel ();
						catch (Exception e) {mprogressdialog.cancel ();
				}.start ();
			Default:break; }

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.