Showdialog (int id) Development Note in Android

Source: Internet
Author: User

I read the source code and see this method.

Linearlayout addaudiobtn = (linearlayout) findviewbyid (R. Id. create_audio_list_header );
Addaudiobtn. setonclicklistener (New onclicklistener (){
@ Override
Public void onclick (view v ){
Showdialog (1); // directly a method in the system activity class
}
});

Explanation in this document

Void Android. App. activity. showdialog (int id)

Simple versionshowDialog(int,
Bundle)
That does not take any arguments. Simply CILSshowDialog(int,
Bundle)
With null arguments.

Parameters:
ID

I used to call this method in my previous development.

Private void showdownloaddialog (){
Downloaddialog = new progressdialog (this );
Downloaddialog. setmessage (getstring (R. String. alert_download_msg ));
Downloaddialog. setcancelable (false );
Downloaddialog. Show ();
}

I took a closer look and used it together with the following method.

@ Override
Protected dialog oncreatedialog (int id ){
Final systemservice = new systemservice (this );
Set <string> folderlist = systemservice. getfoldercontainmedia ();
Choices = folderlist. toarray (New String [folderlist. Size ()]);
// Option Array
// String [] choices = {"Facebook", "Twitter "};
// Check the judgment array, which corresponds to the option
// Boolean [] chsbool = {true, false };
Alertdialog dialog = commonalertdialogbuilder. getinstance (this)
. Seticon (R. drawable. ic_menu_scan). settitle ("select ")
. Setmultichoiceitems (choices, null,
New onmultichoiceclicklistener (){
@ Override
Public void onclick (dialoginterface dialog,
Int which, Boolean ischecked ){
If (ischecked ){
Checkeditem. Add (which );
} Else {
Checkeditem. Remove (object) which );
}
}

}). Setpositivebutton ("yes ",
New dialoginterface. onclicklistener (){
@ Override
Public void onclick (dialoginterface dialog,
Int which ){
// System. Out. println (checkeditem. tostring ());
For (INT I = 0; I <checkeditem. Size (); I ++ ){
// System. Out. println (choices [checkeditem
//. Get (I)]);
Addmediatoplaylist (systemservice
. Getmediasbyfolder (choices [checkeditem
. Get (I)]);
System. Out
. Println (systemservice
. Getmediasbyfolder (
Choices [checkeditem
. Get (I)])
. Tostring ());

}
Showprocessdialog ();
Mrunnable. Run ();
Checkeditem. Clear ();

}

}). Setnegativebutton ("no ",
New dialoginterface. onclicklistener (){

@ Override
Public void onclick (dialoginterface dialog,
Int which ){
Checkeditem. Clear ();
}
}). Create ();
Return dialog;
}

 

Related Article

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.