Android(2)-----Fragment //(第七周后的知识)
生活随笔
收集整理的這篇文章主要介紹了
Android(2)-----Fragment //(第七周后的知识)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、Fragment
android.app.Fragment版本://v4版本是為了由3.0向下兼容到1.6,
改那個(gè)Fragment文件里的import android.support.v4.app.Fragment;
換成 import android.app.Fragment;!!!!!!!!!!!!!
A、首先通過package的new一個(gè)Fragment,將下面兩個(gè)打鉤的去掉
android:orientation="vertical" //垂直居中 android:orientation="horizontal" //水平居中
//compile 'com.android.support:support-v4:26.0.0-alpha1' //這個(gè)版本也可以
android.app.Fragment版本://v4版本是為了由3.0向下兼容到1.6,
改那個(gè)Fragment文件里的import android.support.v4.app.Fragment;
換成 import android.app.Fragment;!!!!!!!!!!!!!
A、首先通過package的new一個(gè)Fragment,將下面兩個(gè)打鉤的去掉
android:orientation="vertical" //垂直居中 android:orientation="horizontal" //水平居中
B、修改app的版本,和Fragment導(dǎo)包的代碼
compile 'com.android.support:support-v4:24.0.0' //import android.support.v4.app.Fragment; import android.app.Fragment;C、在Activity 里使用,使用<fragment>標(biāo)簽,由name屬性指定相關(guān)fragment, 注:要給一個(gè)ID
<fragmentandroid:id="@+id/title_fragment"android:name="com.gdgm.lemon.chapter_fragment.fragment.TitleFragment"android:layout_width="match_parent"android:layout_height="50dp"></fragment>?? 新版本
compile 'com.android.support:support-v4:26.0.0-alpha1'//compile 'com.android.support:support-v4:28.+'//compile 'com.android.support:support-v4:26.0.0-alpha1' //這個(gè)版本也可以
?
?
相關(guān)博客 http://www.cnblogs.com/mengdd/archive/2013/01/08/2851368.html
?android studio導(dǎo)入support -v4 包的方法:
1.進(jìn)入 file-project structure
2.左邊選擇app
3.右邊選擇dependencies
4.左下角可以看到一個(gè)加號(hào),點(diǎn)擊選擇Library dependency就可以看到可以導(dǎo)入的jar包,選擇support-v4導(dǎo)入即可
或者:
1.直接到APP
?轉(zhuǎn)載于:https://www.cnblogs.com/Lemonades/p/10711685.html
總結(jié)
以上是生活随笔為你收集整理的Android(2)-----Fragment //(第七周后的知识)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 消息称苹果正测试M3 Max芯片 用于明
- 下一篇: 每日一问:Android 滑动冲突,你们