Define your own Alertdialog dialog box layout

Source: Internet
Author: User

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

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.