appcompat_v7 and fragment_main.xml?

混江龙づ霸主 提交于 2019-12-10 20:12:39

问题


I've updated my eclipse and ADT Plugin from v22.3 to v22.6 recently and recognised some big changes. Whenever I create a new Android Application Project there appears a new appcompat_v7 library which wasn't present on v22.3 plugin and also a fragment_main.xml file which as I understand is meant to replace activity_main.xml file. Why is that? Why is the activity_main.xml file not preferred for activity layout directly anymore and why appcompat library is now included in every project as a necessity?

Is there a way to bring back the old way of creating projects without losing anything? By the way, I create projects compatible with Android versions from 2.2 to 4.4.


回答1:


Fragment is useful for navigating through layouts of activity.for example if you have two different layout for portrait and landscape mode then you can simply navigate though the different fragments. Secondly, if you can not even get used to it,just remove the default code from activity_main.xml and and cut the fragment_layout.xml and paste it to activity_main. Then delete the code related to fragment in MainActivity.java.Then delete the fragment_main.xml file. Hope it will work.It worked for me.



来源:https://stackoverflow.com/questions/22440407/appcompat-v7-and-fragment-main-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!