Search code examples
androidandroid-fragmentsandroid-dialogfragmentandroid-dialog

Dialog removes fragment from Activity before inflating


I have a funny issue, I had a fragment in my activity and all was working fine, then I introduced a viewpager, my goal was to have a tabbed activity which worked fine but now an issue has risen, I used to inflate a dialog in my fragment, everything would work just as expected but now when I call my dialog seems to be removing all views when it is inflated from my activity including the tabs, does anybody know why?Here is my code

mBottomSheetDialog = new BottomSheetDialog(ManagerActivity.this, R.style.Material_App_BottomSheetDialog);
    parentHolder.removeAllViews();
    View v = LayoutInflater.from(ManagerActivity.this).inflate(R.layout.view_scan_onclick, null);
    ViewUtil.setBackground(v, new ThemeDrawable(R.drawable.bg_window_dark));

Solution

  • The issue you are getting is because removeAllViews() removes all views from layout.