java - How to add a 'Click for more details' expandable field to AlertDialog in android -
java - How to add a 'Click for more details' expandable field to AlertDialog in android -
i have alertdialog shown when there error , prints 'error, not added/whatever", have result of exception i'd parse not shown users, want click on 'details' , read exception.
alertdialog.builder dialogo1 = new alertdialog.builder(activity); dialogo1.settitle("error"); dialogo1.setmessage("could not update movie: " + result); dialogo1.setpositivebutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialogo1, int id) { activity.finish(); } }); dialogo1.show();
there code, pretty simple, right? haven't been able find reply anyway , i'm starting think not possible
what want custom alert dialog. have layout , define dialog.then initialize listeners etc normal view defining
dialog_layout.xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"> <imageview android:src="@drawable/header_logo" android:layout_width="match_parent" android:layout_height="64dp" android:scaletype="center" android:background="#ffffbb33" android:contentdescription="@string/app_name" /> <textview android:id="@+id/error" andorid:text="error message" android:layout_width="match_parent" android:layout_height="wrap_content" /> <button android:id="@+id/moredetailsbutton" android:text="click more details" android:inputtype="textpassword" android:layout_width="match_parent" android:layout_height="wrap_content"/> <textview android:id="@+id/moredetailsview" android:text="click more details" android:inputtype="textpassword" android:layout_width="match_parent" android:visibility="gone"; android:layout_height="wrap_content"/> <button android:id="@+id/dialogbuttonok" android:layout_width="100px" android:layout_height="wrap_content" android:text=" ok " android:layout_margintop="5dp" android:layout_marginright="5dp" android:layout_below="@+id/moredetailsbutton" /> </relativelayout>
and in class
final dialog dialog = new dialog(context); dialog.setcontentview(r.layout.dialog_layout); textview error=(textview)dialog.findviewbyid(r.id.error); button errorbutton=(button)dialog.findviewbyid(r.id.moredetailsbutton); button okbutton=(button)dialog.findviewbyid(r.id.ok); //do whatever want rest of dialog // initialize onclick listeners usual errorbutton.setonclicklistener(new view.onclicklistener(){ @override public void onclick(view v){ textview errordetails=(textview)dialog.findviewbyid(r.id.moredetailsview); errordetails.settext(detailederrormessage) //add details text view; errordetails.setvisibility(view.visible); } }); dialog.show();
sorry if there syntactically errors if ctrl+c,ctrl+v of doesnt work.my ide decided misbehave today.
follow this details on custom alert dialog.
java android alertdialog details
Comments
Post a Comment