1. 在activity中,setContentView(R.layout.fragment); fragment为一个包含fragment的布局文件
2. 布局文件中fragment标签的android:name为fragment的类名,类为继承Fragment的子类
inflater.inflate(R.layout.fragment_button, container, false);
这个类中的 fragment_button 为这个fragment对应的布局文件。
总结:单独创建的布局文件使用fragment作为视图返回,然后在其他的布局文件中用 fragment引用进来。
2. 布局文件中fragment标签的android:name为fragment的类名,类为继承Fragment的子类
inflater.inflate(R.layout.fragment_button, container, false);
这个类中的 fragment_button 为这个fragment对应的布局文件。
总结:单独创建的布局文件使用fragment作为视图返回,然后在其他的布局文件中用 fragment引用进来。
2016-09-21
老师在视频里的7分10秒左右的时候直接敲出android:layout_height="wrap_content"的快捷键是啥?不要说是ctrl+/
2016-09-18
最新回答 / 慕村5414681
老的onAttach直接在attach的时候把fragment的容器Activity通过参数传递给你了,老的在老师的视频里可以实现。但是,新的传递给你的是具体的上下文Context,AS这个IDE里面监视器没VS的好用,无法跟你说Context里怎么找Activity,但是,这个传递过来的context参数里面是包含具体的父容器activity的,所以你可以在super.onAttach(context);这句之后,加getActivity()这个方法来获取父容器activity,这样就不会报错了。用老的...
2016-09-17