Sunday, 15 January 2012

Android: Alert dialog with custom dialog and neutral button -



Android: Alert dialog with custom dialog and neutral button -

i'm editing question improve understanding need, because reply below not giving me proper solution this. so, have create custom alert dialog neutral button @ bottom. here illustration should like:

till have used custom dialog using xml , changing activity android:theme="@android:style/theme.holo.light.dialog", can , sense same. here xml code:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/dialog" android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:id="@+id/login_prompt_header" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:layout_margintop="15dp" android:text="@string/login_prompt_rewards_header" android:textsize="17sp" android:textstyle="bold" > </textview> <textview android:id="@+id/login_prompt_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/login_prompt_header" android:layout_margintop="5dp" android:gravity="center_vertical|center_horizontal" android:paddingleft="18dp" android:paddingright="18dp" android:text="@string/login_prompt_rewards_text" android:textsize="15sp" > </textview> <button android:id="@+id/log_in" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/login_prompt_text" android:layout_centerhorizontal="true" android:layout_gravity="center_horizontal" android:layout_margintop="15dp" android:background="@drawable/log_in" android:contentdescription="@string/none" > </button> <button android:id="@+id/create_account" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/log_in" android:layout_centerhorizontal="true" android:layout_gravity="center_horizontal" android:layout_margintop="10dp" android:background="@drawable/create_account" android:contentdescription="@string/none" > </button> </relativelayout>

by above layout i'm getting next outcome:

the problem i'm facing is: how set neutral button in custom dialog? i'm not getting thought regarding this. if have uncertainty in question or can't understand language please leave comment, can 1 time again give clear idea. help appreciated.

create custom alert dialog like

public void messagedialog(string title, string message, final context activity) { final dialog mydialog = new dialog(activity); mydialog.setcontentview(r.layout.messagescreen); mydialog.settitle(title); mydialog.setcancelable(false); textview text = (textview) mydialog.findviewbyid(r.id.bidmessage); text.setmovementmethod(scrollingmovementmethod.getinstance()); text.settext(message); button login = (button) mydialog.findviewbyid(r.id.buttonlogin); login.setonclicklistener(new onclicklistener() { public void onclick(view v) { mydialog.dismiss(); } }); button createaccount= (button) mydialog.findviewbyid(r.id.buttoncreateaccount); createaccount.setonclicklistener(new onclicklistener() { public void onclick(view v) { mydialog.dismiss(); } }); mydialog.show(); }

where r.layout.messagescreen custom created layout have shown in image. seek out , allow me know if face problem.

android android-widget android-alertdialog android-theme

No comments:

Post a Comment