android - How to show an image from a GridView in an AlertDialog? -
mgridview.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> gridview, view view, int pos, long id) { alertdialog.builder builder = new alertdialog.builder(getactivity()); builder.setview(view); builder.create().show(); } });
when try run code, after click on item, exception:
i don't want remove view parent. want show image in alertdialog
. can give me hint how that?
try this...
mgridview.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> gridview, view view, int pos, long id) { alertdialog.builder builder = new alertdialog.builder(getactivity()); imageview imageview = new imageview(gridview.getcontext()); imageview.setscaletype(imageview.scaletype.center); view.setdrawingcacheenabled(true); view.builddrawingcache(); bitmap bitmap = view.getdrawingcache(); imageview.setimagebitmap(bitmap); builder.setview(imageview); builder.create().show(); } });
Comments
Post a Comment