質問

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?

役に立ちましたか?

解決

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top