Custom dialog created by using your layout file and that file you can
bind your layout to dialog box.And it is useful when we have to
integrate facebook,twitter and all other real word programming.
Steps To Create Custom Dialog
==========================
1. Create your layout which is shown in dialog.
2. Bind that layout file to dialog
3. Show your Dialog on any event.
4. Done
package your package name.CustomDialog;
package com.ss.paresh.DD;
Steps To Create Custom Dialog
==========================
1. Create your layout which is shown in dialog.
2. Bind that layout file to dialog
3. Show your Dialog on any event.
4. Done
1.Layout your android custom dialog in xml file. create new project in android and give name CustomDialog in that layout folder create file login.xml which is your dialog file and write above code.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ff00ff" android:orientation="vertical"> <TextView android:id="@+id/username_view" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="20dip" android:layout_marginRight="20dip" android:text="@string/username" android:gravity="left" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:id="@+id/username_edit" android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_marginLeft="20dip" android:layout_marginRight="20dip" android:scrollHorizontally="true" android:autoText="false" android:singleLine="true" android:capitalize="none" android:gravity="fill_horizontal" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:id="@+id/password_view" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="20dip" android:layout_marginRight="20dip" android:text="@string/password" android:gravity="left" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:id="@+id/password_edit" android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_marginLeft="20dip" android:layout_marginRight="20dip" android:scrollHorizontally="true" android:autoText="false" android:singleLine="true" android:capitalize="none" android:gravity="fill_horizontal" android:password="true" android:textAppearance="?android:attr/textAppearanceMedium" /> </LinearLayout>
2. Now create your second xml file call first.xml file in layout which is shown after login done
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Welcome to First Page" android:textColor="#00ff00" /> </LinearLayout>
3. Now change the code of main.xml file which is available in layout folder to show your dialog in this layout we have put one button.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:orientation="vertical"> <Button android:id="@+id/button" android:layout_width="wrap_content" android:textColorHint="#00FF00" android:textColor="#FF0000" android:textSize="20px" android:layout_height="wrap_content" android:text="Login"/> </LinearLayout>
Custom dialog created by using your layout file and that file you can bind your layout to dialog box.And it is useful when we have to integrate facebook,twitter and all other real word programming.oh its really interesting.
ReplyDeleteApp builder online