i want to build a customized dialog just like the one shown in image:
i
Have a look at this tutorial, it might be of some help.
Check the like here one example that use custom AlertDialog. it help you.
Check the link
Thanks
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:paddingLeft="30dp"
android:text="Add Your View" />
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_margin="10dp"
android:hint="Title" >
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/editText1"
android:layout_margin="10dp"
android:hint="Details" >
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText2"
android:layout_below="@+id/editText2"
android:layout_marginLeft="70dp"
android:layout_marginTop="24dp"
android:text="Add" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_marginRight="70dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button1"
android:layout_alignRight="@+id/editText2"
android:text="Cancel" />
it is the code u need
You just have to inflate the Dialog with your xml file. I'll just give you a sample code, then you can easily follow
private View mView;
private Dialog mDialog;
private LayoutInflater mInflater;
Now create a function as :-
private void showCustomDialog() {
mInflater = (LayoutInflater) getBaseContext().getSystemService(
LAYOUT_INFLATER_SERVICE);
ContextThemeWrapper mTheme = new ContextThemeWrapper(this,
R.style.YOUR_STYE);
mView = mInflater.inflate(R.layout.YOUR_XML_LAYOUT_FILE, null);
// mDialog = new Dialog(this,0); // context, theme
mDialog = new Dialog(mTheme);
mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mDialog.setContentView(this.mView);
mDialog.show();
TextViiew someText = (TextView) mView.findViewById(R.id.textViewID);
// do some thing with the text view or any other view
}
Finally make sure you have the style as :-
<style name="YOUR_STYLE">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowContentOverlay">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
That's it .... you are done... just call this function where ever you want to show the custom dialog....
Hope the explanation was useful....