Added new Activities to a Tabbed Activity
I have added 4 activities to a tabhost widget. These work 开发者_如何转开发fine. The problem is that i have started a new activity from my of my activity that is present in the TabbedHost. This activity is started on a new screen i.e The tabs are no longer visible. How can i start a new activity and it remains within the tabbed host. I hope u understand what i mean?
Kind Regards, Mateen
Hah!! Thats the problem with Tabhost widget dude! They don't allow you to start another activity in the tabhost itself.
The way i worked around is save the state by assigning them to some variables and then change the whole contentView
itself by calling the context.setContentView(R.layout.newLayout)
...
Then after loading the contentView you'll have to override the
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
//check if this has been called by your second view, if yes then
//set the previous ContentView and assign the values accordingly
//else super.onKeyDown(keyCode,event)
}
Worked like a charm for me... you can also do the same thing by having a back button in the second view of yours... Its your call...
you can further refer here...
精彩评论