Android dialog item click

Source: Internet
Author: User

// Enter the dialog style displayed on the Interface

Public void createDialog (){

Builder = newAlertDialog. Builder (Index. this );

Builder. setTitle (R. string. _ index_submenu_title );

Builder. setItems (new String [] {"Start camera", "enable Mobile Camera", "unselect "},

NewDialogInterface. OnClickListener (){

@ Override

Public void onClick (DialogInterfacedialog, intwhich ){

// TODO Auto-generated method stub

// Which starts from 0. To make it also start from 1.

Switch (which + 1 ){

Case IMG_CAMERA:

OpenCamera ();

Break;

Case IMG_FILE:

OpenFile ();

Break;

Case SELECT_CANCEL:

Break;

Default:

Break;

}

}

});

 

}

========================================================== =

Dialog click event:


Public void saveImageDialog (String path ){
ImageView newImage = new ImageView (Index. this );
Bitmap bitmap = MyCommon. fitSizeImg (path, 1 );
NewImage. setImageBitmap (bitmap );
// Display dialog box
New AlertDialog. Builder (Index. this)
. SetTitle ("picture ")
. SetView (newImage)
. SetPositiveButton ("save ",
New DialogInterface. OnClickListener (){


@ Override
Public void onClick (DialogInterface dialog,
Int which ){
// TODO Auto-generated method stub
// Save the image path to the database
ImageDbhelp1.insertlujin (fileName );


Finish ();
Intent intent3 = new Intent (Index. this,
Index. class );
StartActivity (intent3 );
}
}). SetNegativeButton ("cancel", null). show ();


}


Author: kankankankan2222

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.