android - Add custom image to Dialog -
what trying app read qr-codes (referred images) , after reading, showing dialog image related qr-code , description taken database.
any advice on how that?
what find on internet how create dialog custom layout. nothing more.
i assume need t o display image in custom dialog
define dialog.xml
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <imageview android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /> </relativelayout>
in activity on button click display dialog
button b= (button) findviewbyid(r.id.button1); b.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub showpopup(); } }); public void showpopup() { dialog d = new dialog(mainactivity.this); d.setcontentview( r.layout.dialog); d.settitle("my title"); imageview iv = (imageview) d.findviewbyid(r.id.imageview1); iv.setimageresource(r.drawable.afor); // set image here. have used resource drawable folder d.show(); }
Comments
Post a Comment