发表于: 2018-12-02 20:52:29

0 748


一、今天完成的事情

LayoutInflater

LayoutInflater的作用类似于findViewById(),不同的是findViewById()是找xml布局文件下的具体widget控件,比如TextView、ImageView、Button等;LayoutInflater是找res/layout/下的布局文件,并且实例化,具体为:
(1)对于一个没有载入或者想动态载入的界面,需要使用LayoutInflater.inflate()来载入;
(2)对于一个已经载入的页面,可以使用Activity.findViewById()来获取其中的界面元素。
LayoutInflater是一个抽象类,获取它的实例的方式有三种:
(1)LayoutInflater inflater = Activity.getLayoutInflater();
(2)LayoutInflter inflater = LayoutInflater.from(context);
(3)LayoutInflater infalter = (LayoutInflater)context.getSystemService(
                        Context.LAYOUT_INFLATER_SERVICE);

第一和第二种本质上也是getSysztemSevice来获取的。


Fragment嵌套Fragment需要注意的问题

在Fragment中获取FragmentManager的时候,调用的是getChildFragmentManager,而不是getSupportFragmentManager。

       在Activity中获取Fragment:

   getSupportFragmentManager().beginTransaction().add(R.id.fl_fragmenthomeFragment).commit();

        在Fragment 中获取FragmentManager:

getChildFragmentManager().beginTransaction().add(R.id.fl_explore_fragmentfindWorkerFragment).commit();


二、明天的计划

Android SD卡操作


返回列表 返回列表
评论

    分享到