Android - Disable parent view click events when popup window is viewable -
i've spent large amount of time trying solve issue both myself , searching through here find solution, none of have worked me.
my current scenario when popup window appears want disable clickable events on foreground view underneath popup window.
if (shared.inspectiondata.jobviewmodel.rams_id == null || shared.inspectiondata.jobviewmodel.rams_id.equals("")) { // disable foreground view here loadramspopup(); } private void loadramspopup() { mainlayout.getforeground().setalpha(150); layoutinflater layoutinflater = (layoutinflater) getbasecontext().getsystemservice(layout_inflater_service); final view ramsview = layoutinflater.inflate(r.layout.popup_rams, null); final popupwindow popuprams = new popupwindow( ramsview, viewgroup.layoutparams.wrap_content, viewgroup.layoutparams.wrap_content ); if (build.version.sdk_int >= 21) { popuprams.setelevation(5.0f); } findviewbyid(r.id.mainlayout).post(new runnable() { @override public void run() { popuprams.showatlocation(findviewbyid(r.id.mainlayout), gravity.center, 0, 0); popuprams.setoutsidetouchable(false); popuprams.update(); button btngenerate = (button) ramsview.findviewbyid(r.id.btngenerate); btngenerate.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { intent intent = new intent(getapplicationcontext(), createramsactivity.class); startactivity(intent); popuprams.dismiss(); mainlayout.getforeground().setalpha(0); } }); } }); }
hitchhiking off of akshay mukadam disabling child views inside layout. i've tweaked include enabling views.
public static void disableenableviews(viewgroup layout) { layout.setenabled(false); (int = 0; < layout.getchildcount(); i++) { view child = layout.getchildat(i); if (child instanceof viewgroup) { disableenableviews((viewgroup) child); } else { if(child.isenabled()){ child.setenabled(false); } else { child.setenabled(true); } } } }
simply give top view id, reference it, , put method.
Comments
Post a Comment