Not able to implement boolean logic properly

view story

http://stackoverflow.com – Here is what im trying to achieve: I have ActioBar and I have a menu item named Login over the ActionBar. When this login menu item is clicked it adds a new tab in the actionbar and loads the fragment with the login_layout inside the container of the parent activity.And if i click any other tab than the login tab disappears.And it can only reappear if the login menu item is clicked again. Once the login has been successful i want to change the title of the menu item to Log Out.And now after setting title of the Login menu item to Log out if i click it it should not add any tabs on the actiobar (HowTos)