题目内容

4 主视图布局中需要添加一个Fragment;请补全下面的代码;

A. ContentFragment
B. TitleFragment
C. MainAcitivty
D. Activity

查看答案
更多问题

5 TitleFragment中访问ContentFragment的方法,请补全下列代码?ContentFragment mContentFragment=(ContentFragment)getActivity(). ( ? ).findFragmentById(R.id.fragment_content); mContentFragment.setData(strTitle,strContent);

A. getSupportManager()
B. getManager()
C. getFrament()
D. getSupportFragmentManager()

6 Activity中如果加载多个Fragment,初始化显示第一个Fragment,请补全下面的代码?private void initFragment() { getSupportFragmentManager().( ?).replace(R.id.main_fm,new Fragment1()).commit(); }

A. Transaction()
B. begin()
C. beginTransaction()
D. getFrament()

7 Fragment可以实现动态加载,下面是实现动态加载的过程,请补全代码?private void replaceFragment(int layout,Fragment fragment){ FragmentManager manager=getSupportFragmentManager(); FragmentTransaction fragmentTransaction=manager.beginTransaction(); fragmentTransaction.replace(layout,fragment); fragmentTransaction.addToBackStack(null); ( ? ); }

A. fragmentTransaction.getFragmentById()
B. fragmentTransaction.getAcitivity()
C. fragmentTransaction.commitFragment()
D. fragmentTransaction.commit()

8Activity中如果加载多个Fragment,切换显示第三个Fragment,请问下面的代码哪些能实现()?

A. replaceFragment(R.id.main_fm,new Fragment1())
B. replaceFragment(R.id.main_fm,new Fragment2())
C. replaceFragment(R.id.main_fm,new Fragment3())
D. replaceFragment(R.id.main_fm,new Fragment4())

答案查题题库