安卓实习第八天

来源:互联网 发布:2d旋转矩阵 编辑:程序博客网 时间:2024/04/29 12:54
  • Fragment怎么获得Activity的控件:
rootview = getActivity().getWindow().getDecorView();search_flowLayout = (FlowLayout)view.findViewById(R.id.search_flowLayout);
  • Fragment之间切换
AnotherRightFragment fragment = new AnotherRightFragment();FragmentManager fragmentManager = getFragmentManager();FragmentTransaction transaction = fragmentManager.beginTransaction();transaction.replace(R.id.right_layout, fragment);   //切记,right_layout是fragment的父布局transaction.addToBackStack(null);transaction.commit(); 
  • 在Activity中获取另一个xml布局的元素
LayoutInflater layout=this.getLayoutInflater();View view=layout.inflate(R.layout.login_stytle, null);Button b=(Button)view.findViewById(R.id.b);
  • 给listview加头部
LinearLayout header = (LinearLayout) inflater.inflate(R.layout.search_listview_header,null);search_history_list.addHeaderView(header,null,false); //第三个参数表示头部不可选择
0 0
原创粉丝点击