我有两个活动。其中之一是显示图表,另一个是显示派图表。我想将两者嵌入一个单一的启动活动。允许用户进行单击,以切换线图和派图表。
我知道ActionBar的导航标签, 或下降导航 是帮助我达到这个目的的最佳人选。
从“Adroid API”演示和http://developer.android.com/guide/topics/ui/ actionbar.html ,我意识到所有转换的部件都以 Fragment
而不是 Actionity
的方式执行。
- Does it mean that I need to port my previous 2 Activities into 2 Fragments, in order to embed them into ActionBar s tab navigation view/ drop-down navigation view?
- Is there any other ways I can do without porting? But, is it advisable as I do not find an official example by using Activity.
- In API demo, I realize most Fragment is implemented in the following pattern.
public class FragmentStack extends Activity {
...
public static class CountingFragment extends Fragment {
// CountingFragment never access any members in FragmentStack
}
}
这样做有任何理由吗? 为什么他们没有CountingForfication
是一个分离的文件?