如何正确的在fragment中显示surfaceview
2016-07-30
展开全部
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
Tab_P1 = actionBar.newTab();
Tab_P1.setCustomView(R.layout.tab_layout_dong);
Tab_P2 = actionBar.newTab();
Tab_P2.setCustomView(R.layout.tab_layout_nan);
fragment_P1 = new Fragment_P1();
MyTabListener AListener=new MyTabListener(fragment_P1);
Tab_P1.setTabListener(AListener);
fragment_P2 = new Fragment_P2();
MyTabListener BListener=new MyTabListener(fragment_P2);
Tab_P2.setTabListener(BListener);
actionBar.addTab(Tab_P1);
actionBar.addTab(Tab_P2);
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.fragment_place, fragment_P1);
transaction.commit();
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
Tab_P1 = actionBar.newTab();
Tab_P1.setCustomView(R.layout.tab_layout_dong);
Tab_P2 = actionBar.newTab();
Tab_P2.setCustomView(R.layout.tab_layout_nan);
fragment_P1 = new Fragment_P1();
MyTabListener AListener=new MyTabListener(fragment_P1);
Tab_P1.setTabListener(AListener);
fragment_P2 = new Fragment_P2();
MyTabListener BListener=new MyTabListener(fragment_P2);
Tab_P2.setTabListener(BListener);
actionBar.addTab(Tab_P1);
actionBar.addTab(Tab_P2);
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.fragment_place, fragment_P1);
transaction.commit();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询