The question i have is a bit difficult to explain so please bear with me,
I have implemented actionBar for an app, the thing is i have 5-6 menu items on the actionBar and handling the click event using
onOptionsItemSelected(MenuItem item)
what happens is each menu item click inflates a particular view in a common region[i.e the inflated views overlap each other,not a common container],
i need to remove that view and inflate another one if another item is clicked,and i achieve this using simple if comparison statements.
While the solution is simple,implementing it and checking for so many conditions makes it complex and the code unreadable.
I just want to know if there exists a more elegant solution for this problem?
Keep a reference to the last inflated view:
in the
onOptionsItemSelectedmethod hide the view with this reference and set it to the next inflated.