• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

App Inventor toolbar.addView?

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
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)
 
Implement own onBackPressed with overriding in Activity then you can do some work inside and after you are done you can call original by super.onBackPressed();

or you can implement a listener for key back pressed

by the way, can you provide more code? it will help to understand whats going on :)
 
Back
Top Bottom