问题
This is actually extended version of Alternatives to using an activity for each tab. The point is using views instead of activity is actually a good idea. If I have a button or some text then its fine. But what if I actually want an activity to be started on tab change, like a camera ? Is it still efficient to use views instead of activity ? If so, how do I do it ? Because calling new intent everytime is also heavy on memory I think.
回答1:
If you want an activity launched with a tab change, then use activities. Don't get hung up on efficiency unless you're certain you have problems.
Views are presumably more efficient because they don't launch an activity, but since you're launching an activity anyway, what do you gain? I use tabbed activities in my app and they're fine, even on my underpowered phone.
Remember...
"Premature optimisation is the root of all evil"
回答2:
But what if I actually want an activity to be started on tab change, like a camera ?
You cannot start an activity on a tab change. You cannot integrate a third-party activity (e.g., built in camera activity) in a tab.
Hence, if you want a camera preview in a tab, you have no choice but to do your own work with the Camera
object and a SurfaceView
.
来源:https://stackoverflow.com/questions/5784821/using-views-instead-of-an-activity-for-each-tab