Define your own information in the dialog box body layout
Layoutinflater inflater =getlayoutinflater (); View layout = inflater.inflate (r.layout.alert_dialog_content, NULL); Alertdialog Musicdialog = new Alertdialog.builder (this, alertdialog.theme_holo_light). Create (); Musicdialog.setview (layout); TextView TextView = (TextView) Layout.findviewbyid (r.id.message); Textview.settext (MDIALOGDESC); Musicdialog.settitle (R.string.delete_item); Musicdialog.setbutton (Dialoginterface.button_positive, Getresources (). getString (R.string.delete_confirm_button_ Text), mbuttonclicked); Musicdialog.setbutton (Dialoginterface.button_neutral, Getresources (). getString (R.string.cancel), mButtonClicked) ; Musicdialog.setcanceledontouchoutside (TRUE); Musicdialog.setcancelable (TRUE); Musicdialog.setonkeylistener (Msearchkeylistener); Musicdialog.seticon (ANdroid. R.drawable.ic_dialog_alert); return musicdialog;
Layout file:
<?XML version= "1.0" encoding= "Utf-8"?> <!--* * * Copyright, the Android Open Source Project * * * Licensed under the Apache License, Version 2.0 (the "License"); * * Do not use this file except in compliance with the License. * * Obtain a copy of the License at * * * * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * unless requ Ired by applicable/agreed to in writing, software * Distributed under the License is distributed on a "as is" B ASIS, * * without warranties or CONDITIONS of any KIND, either express or implied. * * See the License for the specific language governing permissions and * * Limitations under the License. */-<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" android:id= "@+id/ Parentpanel "android:layout_width=" match_parent "android:layout_height=" Wrap_content "Android:layout_mar Ginstart= "8dip" android:layout_marginend= "8dip" android:orientation= "vertical" > <linearlayout android:id= "@+id/contentpanel" Android:layout_w Idth= "Match_parent" android:layout_height= "wrap_content" android:paddingtop= "12dip" Android: Paddingbottom= "12dip" android:orientation= "vertical" > <scrollview android:id= "@+id/scrollview" Android:layout_width= "Match_parent" android:layout_height= "Wrap_content" > < TextView android:id= "@+id/message" style= "? Android:attr/textappearancemedium" Android: Layout_width= "Match_parent" android:layout_height= "Wrap_content" android:paddingstart= "16dip" android:paddingend= "16dip" android:paddingtop= "8dip" Android :p addingbottom= "8dip"/> </ScrollView> </LinearLayout> </LinearLayout>
Define your own Alertdialog dialog box layout