umtblbl
Member
Hi friends, I have added a layout file to the fragment in the subfragments with addView in the toolbar I defined in BaseFragment. However, when you press the back button, the layout added with addView is still there. How do I clear this layout in the previous fragment after pressing the back button?
previous fragment
previous fragment
Code:
val toolbar = requireActivity().findViewById<Toolbar>(R.id.toolbar_usersearch)
toolbar.menu.clear() //This clears the menu, I want to clear the added layout.
toolbar.inflateMenu(R.menu.toolbar_menu_searchprofile)
toolbar.setOnMenuItemClickListener(this::onOptionsItemSelected)