I am using FragmentTabHost in my app. I have three tabs. Each tab shows a Fragment.
addTab("Tab1", R.drawable.ic_launcher, Fragment1.class);
addTab("Tab2", R.drawable.ic_launcher, Fragment2.class);
addTab("Tab3", R.drawable.ic_launcher, Fragment3.class);
addTab("Tab3", R.drawable.ic_launcher, Fragment4.class);
When I press back from any of these tabs, the app is closed and home screen is shown. Now what I want is, when I press back from Tab1, the app should close. However, if I press back from Tab2 or Tab3, the user should be sent to Tab1. Summary is:
Currently in Tab1 -> press back -> app close
Currently in Tab2 -> press back -> Go to Tab1
Currently in Tab3 -> press back -> Go to Tab1
How can I achieve this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…