I want to add my own style pop-up dialogue box in my android app as shown in image -
this question has answer here:
- android custom popupwindow/dialog 2 answers
as shown in image above part layout , want add pop-up part below in image.so how can create , how can handle dialogue box button event.??
public class popupforeditactivity extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.alphabetslist); callalertdialoguecustom(); } public void callalertdialoguecustom(){ final dialog dialog = new dialog(popupforeditactivity.this); dialog.setcontentview(r.layout.popup); // custom layout dialog.settitle("this custom dialog box"); dialog.setcancelable(true); //there lot of settings, dialog, check them out! //set text textview text = (textview) dialog.findviewbyid(r.id.txt1); text.settext("lots of hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"); edittext edt=(edittext) dialog.findviewbyid(r.id.edtxtname); edt.settext("i binded time"); //set image view /* imageview img = (imageview) dialog.findviewbyid(r.id.imageview01); img.setimageresource(r.drawable.nista_logo);*/ //set button button button = (button) dialog.findviewbyid(r.id.btnsave); button.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { toast.maketext(getapplicationcontext(), "you clicked on save", toast.length_short).show(); dialog.dismiss(); } }); button button1 = (button) dialog.findviewbyid(r.id.btncancel); button1.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { //finish(); dialog.dismiss(); } }); //now dialog set up, it's time show dialog.show(); } }
my custom layout gui
xml
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rltvview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/bg_black_transparent"> <scrollview android:id="@+id/scrlview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginleft="20dip" android:layout_marginright="20dip" android:layout_centerinparent="true" android:background="@android:color/darker_gray" > <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <textview android:id="@+id/txt1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:paddingleft="5dip" android:layout_margintop="15dip" android:text="name" android:textcolor="@android:color/black" android:background="@drawable/btn_orange_matte"/> <edittext android:id="@+id/edtxtname" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginleft="10dip" android:layout_marginright="10dip" android:layout_margintop="10dip" android:scrollbars="vertical" android:hint="hii" android:lines="5" android:singleline="false" android:textcolor="@android:color/black" /> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightsum="1"> <button android:id="@+id/btnsave" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight=".5" android:text="save" android:layout_margin="10dip"/> <button android:id="@+id/btncancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight=".5" android:text="cancel" android:layout_margin="10dip"/> </linearlayout> </linearlayout> </scrollview> </relativelayout>
just call callalertdialoguecustom(); method place according need.. create custom dialogue , handle click events it
Comments
Post a Comment