Sometimes you need to customize the dialog box, you can use Alterdialog.bulider, such as the following code snippet
1 New Alertdialog.builder (self) 2 3 . Settitle ("title")45 . Setmessage ("Simple message box")67 NULL )89 . Show ();
The code snippet above is from: http://blog.csdn.net/chenlei1889/article/details/6267406
What I want to record here is to implement a custom dialog box by inheriting the dialog class.
Layout file Menu.xml under the Layout folder
<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"android:orientation= "vertical"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"> <TextViewAndroid:text= "User name"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:textsize= "20SP" /> <EditTextAndroid:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"Android:id= "@+id/user" /> <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Password"android:textsize= "20SP" /> <EditTextAndroid:id= "@+id/password"Android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"Android:password= "true" /></LinearLayout>
Java Code (fragment)
1 New Mydialog (Activity_first. this); 2 Mydialog.show ();
Android Inheritance Dialog Implementation Customization dialog box