Activity_main.xml:
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
android:orientation= "vertical" android:layout_width= "match_parent"
android:layout_height= "Match_parent" >
<button
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:text= The Customize View dialog box
Android:id= "@+id/btncustomviewdialog"
/>
</LinearLayout>
Dialog_custom.xml
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
android:orientation= "vertical" android:layout_width= "match_parent"
android:layout_height= "Match_parent" >
<progressbar
Style= "? Android:attr/progressbarstylelarge"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:id= "@+id/progressbar"
android:layout_gravity= "Center_horizontal"/>
<textview
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:text= "Loading ..."/>
</LinearLayout>
Mainactivity.java:
This.findviewbyid (R.id.btncustomviewdialog). Setonclicklistener (New View.onclicklistener () {
@Override
public void OnClick (View v) {
Alertdialog.builder Builder = new Alertdialog.builder (mainactivity.this);
Builder.settitle ("Custom View");
View view = View.inflate (Mainactivity.this,r.layout.dialog_custom,null);
Builder.setview (view);
Builder.show ();
}
});
Android Display Custom View dialog box