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;
}