0

I have a homescreen in my app that doesn't have any tabs. It just has a series of buttons. Clicking a button launches the new activity that contains a tabbar at the top. This functions normally. I can click through all the tabs just fine. What I'd like to do though is add another tab that doesn't really have content but instead, when clicked, will take the user back to the homescreen. Is this possible, and if so how would I go about doing this?

LoneWolfPR
  • 3,978
  • 12
  • 48
  • 84
  • It's possible, but weird. Users are intimately familiar with tab usage in a way that will make your behavior completely unexpected. The ActionBar up action is more appropriate for this type of navigation event. – Krylez Oct 11 '13 at 19:23

1 Answers1

0

What about just closing the "tabbar at the top"- Activity with finish(). Your homescreen is right under if you did not finish() it. This is IMHO the most basic way to navigate in Android.

Another way is from your "tabbar at the top"- Activity you could do this

Intent intent = new Intent(this,homescreen.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

This should kill your "tabbar at the top"- Activity and start homescreen activity if it's not started. If it's started it will pop up

Check this How do you use Intent.FLAG_ACTIVITY_CLEAR_TOP

Community
  • 1
  • 1
Erik
  • 5,039
  • 10
  • 63
  • 119
  • I basically did this. I assigned a dummy class to the Home tab, so that it wouldn't crash the app when clicked. Then inside the fragmenttabhost I used `onTabChanged` to check for the home tab being clicked. If it is I finish the activity. So the home activity shows. – LoneWolfPR Oct 11 '13 at 19:40