Android Fragment 基本了解(圖文介紹)
更新時間:2013年01月10日 09:33:47 作者:
Android是在Android 3.0 (API level 11)開始引入Fragment的可以把Fragment想成Activity中的模塊,這個模塊有自己的布局,有自己的生命周期,單獨處理自己的輸入,在Activity運行的時候可以加載或者移除Fragment模塊
Fragment
Android是在Android 3.0 (API level 11)開始引入Fragment的。
可以把Fragment想成Activity中的模塊,這個模塊有自己的布局,有自己的生命周期,單獨處理自己的輸入,在Activity運行的時候可以加載或者移除Fragment模塊。
可以把Fragment設(shè)計成可以在多個Activity中復(fù)用的模塊。
當(dāng)開發(fā)的應(yīng)用程序同時適用于平板電腦和手機時,可以利用Fragment實現(xiàn)靈活的布局,改善用戶體驗。
如圖:
Fragment的生命周期
因為Fragment必須嵌入在Acitivity中使用,所以Fragment的生命周期和它所在的Activity是密切相關(guān)的。
如果Activity是暫停狀態(tài),其中所有的Fragment都是暫停狀態(tài);如果Activity是stopped狀態(tài),這個Activity中所有的Fragment都不能被啟動;如果Activity被銷毀,那么它其中的所有Fragment都會被銷毀。
但是,當(dāng)Activity在活動狀態(tài),可以獨立控制Fragment的狀態(tài),比如加上或者移除Fragment。
當(dāng)這樣進行fragment transaction(轉(zhuǎn)換)的時候,可以把fragment放入Activity的back stack中,這樣用戶就可以進行返回操作。
Fragment的使用相關(guān)
使用Fragment時,需要繼承Fragment或者Fragment的子類(DialogFragment, ListFragment, PreferenceFragment, WebViewFragment),所以Fragment的代碼看起來和Activity的類似。
使用Support Library
Support Library是一個提供了API庫函數(shù)的JAR文件,這樣就可以在舊版本的Android上使用一些新版本的APIs。
比如android-support-v4.jar.它的完整路徑是:
<sdk>/extras/android/support/v4/android-support-v4.jar.
它就提供了Fragment的APIs,使得在Android 1.6 (API level 4)以上的系統(tǒng)都可以使用Fragment。
為了確定沒有在舊版本系統(tǒng)上使用新版本的APIs,需要如下導(dǎo)入語句:
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
同時應(yīng)該將上述的包拷入libs項目下的libs文件夾,然后在項目的Properties中添加:右鍵單擊項目,選Properties,左邊選Java Build Path,然后Add External JARs…,添加android-support-v4.jar.
當(dāng)創(chuàng)建包含F(xiàn)ragment的Activity時,如果用的是Support Library,那么繼承的就應(yīng)該是FragmentActivity而不是Activity。
必須實現(xiàn)的三個回調(diào)函數(shù)
onCreate()
系統(tǒng)在創(chuàng)建Fragment的時候調(diào)用這個方法,這里應(yīng)該初始化相關(guān)的組件,一些即便是被暫停或者被停止時依然需要保留的東西。
onCreateView()
當(dāng)?shù)谝淮卫L制Fragment的UI時系統(tǒng)調(diào)用這個方法,必須返回一個View,如果Fragment不提供UI也可以返回null。
注意,如果繼承自ListFragment,onCreateView()默認的實現(xiàn)會返回一個ListView,所以不用自己實現(xiàn)。
onPause()
當(dāng)用戶離開Fragment時第一個調(diào)用這個方法,需要提交一些變化,因為用戶很可能不再返回來。
實現(xiàn)Fragment的UI
提供Fragment的UI,必須實現(xiàn)onCreateView()方法。
假設(shè)Fragment的布局設(shè)置寫在example_fragment.xml資源文件中,那么onCreateView()方法可以如下寫:
public static class ExampleFragment extends Fragment
{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
// Inflate the layout for this fragment
return inflater.inflate(R.layout.example_fragment, container, false);
}
}
onCreateView()中container參數(shù)代表該Fragment在Activity中的父控件;savedInstanceState提供了上一個實例的數(shù)據(jù)。
inflate()方法的三個參數(shù):
第一個是resource ID,指明了當(dāng)前的Fragment對應(yīng)的資源文件;
第二個參數(shù)是父容器控件;
第三個布爾值參數(shù)表明是否連接該布局和其父容器控件,在這里的情況設(shè)置為false,因為系統(tǒng)已經(jīng)插入了這個布局到父控件,設(shè)置為true將會產(chǎn)生多余的一個View Group。
把Fragment加入Activity
當(dāng)Fragment被加入Activity中時,它會處在對應(yīng)的View Group中。
Fragment有兩種加載方式:一種是在Activity的layout中使用標(biāo)簽<fragment>聲明;另一種方法是在代碼中把它加入到一個指定的ViewGroup中。
另外,F(xiàn)ragment它可以并不是Activity布局中的任何一部分,它可以是一個不可見的部分。這部分內(nèi)容先略過。
加載方式1:通過Activity的布局文件將Fragment加入Activity
在Activity的布局文件中,將Fragment作為一個子標(biāo)簽加入即可。
如:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:name="com.example.news.ArticleListFragment"
android:id="@+id/list"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent" />
<fragment android:name="com.example.news.ArticleReaderFragment"
android:id="@+id/viewer"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="match_parent" />
</LinearLayout>
其中android:name屬性填上你自己創(chuàng)建的fragment的完整類名。
當(dāng)系統(tǒng)創(chuàng)建這個Activity的布局文件時,系統(tǒng)會實例化每一個fragment,并且調(diào)用它們的onCreateView()方法,來獲得相應(yīng)fragment的布局,并將返回值插入fragment標(biāo)簽所在的地方。
有三種方法為Fragment提供ID:
android:id屬性:唯一的id
android:tag屬性:唯一的字符串
如果上面兩個都沒提供,系統(tǒng)使用容器view的ID。
加載方式2:通過編程的方式將Fragment加入到一個ViewGroup中
當(dāng)Activity處于Running狀態(tài)下的時候,可以在Activity的布局中動態(tài)地加入Fragment,只需要指定加入這個Fragment的父View Group即可。
首先,需要一個FragmentTransaction實例:
FragmentManager fragmentManager = getFragmentManager()
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();(注,如果import android.support.v4.app.FragmentManager;那么使用的是:FragmentManager fragmentManager = getSupportFragmentManager();)
之后,用add()方法加上Fragment的對象:
ExampleFragment fragment = new ExampleFragment();
fragmentTransaction.add(R.id.fragment_container, fragment);
fragmentTransaction.commit();
其中第一個參數(shù)是這個fragment的容器,即父控件組。
最后需要調(diào)用commit()方法使得FragmentTransaction實例的改變生效。
實例
練習(xí)的例子:
寫一個類繼承自Fragment類,并且寫好其布局文件(本例中是兩個TextView),在Fragment類的onCreateView()方法中加入該布局。
之后用兩種方法在Activity中加入這個fragment:
第一種是在Activity的布局文件中加入<fragment>標(biāo)簽;
第二種是在Activity的代碼中使用FragmentTransaction的add()方法加入fragment。
貼出代碼:
自己定義的fragment類:
ExampleFragment.java
package com.example.learningfragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class ExampleFragment extends Fragment
{
//三個一般必須重載的方法
@Override
public void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
System.out.println("ExampleFragment--onCreate");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
System.out.println("ExampleFragment--onCreateView");
return inflater.inflate(R.layout.example_fragment_layout, container, false);
}
@Override
public void onPause()
{
// TODO Auto-generated method stub
super.onPause();
System.out.println("ExampleFragment--onPause");
}
@Override
public void onResume()
{
// TODO Auto-generated method stub
super.onResume();
System.out.println("ExampleFragment--onResume");
}
@Override
public void onStop()
{
// TODO Auto-generated method stub
super.onStop();
System.out.println("ExampleFragment--onStop");
}
}
fragment的布局文件:
example_fragment_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/num1"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/num2"
/>
</LinearLayout>
主Activity:
LearnFragment.java
package com.example.learningfragment;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
public class LearnFragment extends FragmentActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_learn_fragment);
//在程序中加入Fragment
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
ExampleFragment fragment = new ExampleFragment();
fragmentTransaction.add(R.id.linear, fragment);
fragmentTransaction.commit();
}
}
Activity的布局文件:
activity_learn_fragment.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<Button
android:id="@+id/btn1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/btn1"
/>
<fragment
android:name="com.example.learningfragment.ExampleFragment"
android:id="@+id/fragment1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/btn2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/btn2"
/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<Button
android:id="@+id/btn3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/btn3"
/>
</LinearLayout>
</LinearLayout>
運行結(jié)果如下:
可以看到第二種方式加入fragment的時候,指定了父容器(一個線性布局)的id,其中已經(jīng)有一個Button 3,所以fragment加在其后。
參考資源
Fragment類文檔:
http://developer.android.com/reference/android/app/Fragment.html
Training:Building a Dynamic UI with Fragments
http://developer.android.com/training/basics/fragments/index.html
Fragments Develop Guide:
http://developer.android.com/guide/components/fragments.html
Android是在Android 3.0 (API level 11)開始引入Fragment的。
可以把Fragment想成Activity中的模塊,這個模塊有自己的布局,有自己的生命周期,單獨處理自己的輸入,在Activity運行的時候可以加載或者移除Fragment模塊。
可以把Fragment設(shè)計成可以在多個Activity中復(fù)用的模塊。
當(dāng)開發(fā)的應(yīng)用程序同時適用于平板電腦和手機時,可以利用Fragment實現(xiàn)靈活的布局,改善用戶體驗。
如圖:

Fragment的生命周期
因為Fragment必須嵌入在Acitivity中使用,所以Fragment的生命周期和它所在的Activity是密切相關(guān)的。
如果Activity是暫停狀態(tài),其中所有的Fragment都是暫停狀態(tài);如果Activity是stopped狀態(tài),這個Activity中所有的Fragment都不能被啟動;如果Activity被銷毀,那么它其中的所有Fragment都會被銷毀。
但是,當(dāng)Activity在活動狀態(tài),可以獨立控制Fragment的狀態(tài),比如加上或者移除Fragment。
當(dāng)這樣進行fragment transaction(轉(zhuǎn)換)的時候,可以把fragment放入Activity的back stack中,這樣用戶就可以進行返回操作。

Fragment的使用相關(guān)
使用Fragment時,需要繼承Fragment或者Fragment的子類(DialogFragment, ListFragment, PreferenceFragment, WebViewFragment),所以Fragment的代碼看起來和Activity的類似。
使用Support Library
Support Library是一個提供了API庫函數(shù)的JAR文件,這樣就可以在舊版本的Android上使用一些新版本的APIs。
比如android-support-v4.jar.它的完整路徑是:
<sdk>/extras/android/support/v4/android-support-v4.jar.
它就提供了Fragment的APIs,使得在Android 1.6 (API level 4)以上的系統(tǒng)都可以使用Fragment。
為了確定沒有在舊版本系統(tǒng)上使用新版本的APIs,需要如下導(dǎo)入語句:
復(fù)制代碼 代碼如下:
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
同時應(yīng)該將上述的包拷入libs項目下的libs文件夾,然后在項目的Properties中添加:右鍵單擊項目,選Properties,左邊選Java Build Path,然后Add External JARs…,添加android-support-v4.jar.

當(dāng)創(chuàng)建包含F(xiàn)ragment的Activity時,如果用的是Support Library,那么繼承的就應(yīng)該是FragmentActivity而不是Activity。
必須實現(xiàn)的三個回調(diào)函數(shù)
onCreate()
系統(tǒng)在創(chuàng)建Fragment的時候調(diào)用這個方法,這里應(yīng)該初始化相關(guān)的組件,一些即便是被暫停或者被停止時依然需要保留的東西。
onCreateView()
當(dāng)?shù)谝淮卫L制Fragment的UI時系統(tǒng)調(diào)用這個方法,必須返回一個View,如果Fragment不提供UI也可以返回null。
注意,如果繼承自ListFragment,onCreateView()默認的實現(xiàn)會返回一個ListView,所以不用自己實現(xiàn)。
onPause()
當(dāng)用戶離開Fragment時第一個調(diào)用這個方法,需要提交一些變化,因為用戶很可能不再返回來。
實現(xiàn)Fragment的UI
提供Fragment的UI,必須實現(xiàn)onCreateView()方法。
假設(shè)Fragment的布局設(shè)置寫在example_fragment.xml資源文件中,那么onCreateView()方法可以如下寫:
復(fù)制代碼 代碼如下:
public static class ExampleFragment extends Fragment
{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
// Inflate the layout for this fragment
return inflater.inflate(R.layout.example_fragment, container, false);
}
}
onCreateView()中container參數(shù)代表該Fragment在Activity中的父控件;savedInstanceState提供了上一個實例的數(shù)據(jù)。
inflate()方法的三個參數(shù):
第一個是resource ID,指明了當(dāng)前的Fragment對應(yīng)的資源文件;
第二個參數(shù)是父容器控件;
第三個布爾值參數(shù)表明是否連接該布局和其父容器控件,在這里的情況設(shè)置為false,因為系統(tǒng)已經(jīng)插入了這個布局到父控件,設(shè)置為true將會產(chǎn)生多余的一個View Group。
把Fragment加入Activity
當(dāng)Fragment被加入Activity中時,它會處在對應(yīng)的View Group中。
Fragment有兩種加載方式:一種是在Activity的layout中使用標(biāo)簽<fragment>聲明;另一種方法是在代碼中把它加入到一個指定的ViewGroup中。
另外,F(xiàn)ragment它可以并不是Activity布局中的任何一部分,它可以是一個不可見的部分。這部分內(nèi)容先略過。
加載方式1:通過Activity的布局文件將Fragment加入Activity
在Activity的布局文件中,將Fragment作為一個子標(biāo)簽加入即可。
如:
復(fù)制代碼 代碼如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:name="com.example.news.ArticleListFragment"
android:id="@+id/list"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent" />
<fragment android:name="com.example.news.ArticleReaderFragment"
android:id="@+id/viewer"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="match_parent" />
</LinearLayout>
其中android:name屬性填上你自己創(chuàng)建的fragment的完整類名。
當(dāng)系統(tǒng)創(chuàng)建這個Activity的布局文件時,系統(tǒng)會實例化每一個fragment,并且調(diào)用它們的onCreateView()方法,來獲得相應(yīng)fragment的布局,并將返回值插入fragment標(biāo)簽所在的地方。
有三種方法為Fragment提供ID:
android:id屬性:唯一的id
android:tag屬性:唯一的字符串
如果上面兩個都沒提供,系統(tǒng)使用容器view的ID。
加載方式2:通過編程的方式將Fragment加入到一個ViewGroup中
當(dāng)Activity處于Running狀態(tài)下的時候,可以在Activity的布局中動態(tài)地加入Fragment,只需要指定加入這個Fragment的父View Group即可。
首先,需要一個FragmentTransaction實例:
FragmentManager fragmentManager = getFragmentManager()
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();(注,如果import android.support.v4.app.FragmentManager;那么使用的是:FragmentManager fragmentManager = getSupportFragmentManager();)
之后,用add()方法加上Fragment的對象:
ExampleFragment fragment = new ExampleFragment();
fragmentTransaction.add(R.id.fragment_container, fragment);
fragmentTransaction.commit();
其中第一個參數(shù)是這個fragment的容器,即父控件組。
最后需要調(diào)用commit()方法使得FragmentTransaction實例的改變生效。
實例
練習(xí)的例子:
寫一個類繼承自Fragment類,并且寫好其布局文件(本例中是兩個TextView),在Fragment類的onCreateView()方法中加入該布局。
之后用兩種方法在Activity中加入這個fragment:
第一種是在Activity的布局文件中加入<fragment>標(biāo)簽;
第二種是在Activity的代碼中使用FragmentTransaction的add()方法加入fragment。
貼出代碼:
自己定義的fragment類:
復(fù)制代碼 代碼如下:
ExampleFragment.java
package com.example.learningfragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class ExampleFragment extends Fragment
{
//三個一般必須重載的方法
@Override
public void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
System.out.println("ExampleFragment--onCreate");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
System.out.println("ExampleFragment--onCreateView");
return inflater.inflate(R.layout.example_fragment_layout, container, false);
}
@Override
public void onPause()
{
// TODO Auto-generated method stub
super.onPause();
System.out.println("ExampleFragment--onPause");
}
@Override
public void onResume()
{
// TODO Auto-generated method stub
super.onResume();
System.out.println("ExampleFragment--onResume");
}
@Override
public void onStop()
{
// TODO Auto-generated method stub
super.onStop();
System.out.println("ExampleFragment--onStop");
}
}
fragment的布局文件:
復(fù)制代碼 代碼如下:
example_fragment_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/num1"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/num2"
/>
</LinearLayout>
主Activity:
復(fù)制代碼 代碼如下:
LearnFragment.java
package com.example.learningfragment;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
public class LearnFragment extends FragmentActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_learn_fragment);
//在程序中加入Fragment
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
ExampleFragment fragment = new ExampleFragment();
fragmentTransaction.add(R.id.linear, fragment);
fragmentTransaction.commit();
}
}
Activity的布局文件:
復(fù)制代碼 代碼如下:
activity_learn_fragment.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<Button
android:id="@+id/btn1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/btn1"
/>
<fragment
android:name="com.example.learningfragment.ExampleFragment"
android:id="@+id/fragment1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/btn2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/btn2"
/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<Button
android:id="@+id/btn3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/btn3"
/>
</LinearLayout>
</LinearLayout>
運行結(jié)果如下:

參考資源
Fragment類文檔:
http://developer.android.com/reference/android/app/Fragment.html
Training:Building a Dynamic UI with Fragments
http://developer.android.com/training/basics/fragments/index.html
Fragments Develop Guide:
http://developer.android.com/guide/components/fragments.html
您可能感興趣的文章:
- Android基礎(chǔ)之使用Fragment控制切換多個頁面
- Android基礎(chǔ)之Fragment與Activity交互詳解
- Android中fragment嵌套fragment問題解決方法
- Android程序開發(fā)之Fragment實現(xiàn)底部導(dǎo)航欄實例代碼
- Android的Fragment的生命周期各狀態(tài)和回調(diào)函數(shù)使用
- Android fragment實現(xiàn)多個頁面切換效果
- Android 管理Activity中的fragments
- Fragment里添加ListView不要用ListFragment
- FrameLayout和Fragment處理Android應(yīng)用UI布局實例
- 安卓開發(fā)之FragmentPagerAdapter和FragmentStatePagerAdapter詳解
相關(guān)文章
Android三方依賴沖突Gradle中exclude的使用
這篇文章主要介紹了Android三方依賴沖突Gradle中exclude的使用,文章圍繞主題展開詳細的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下2022-09-09Android 使用ContentObserver監(jiān)聽數(shù)據(jù)庫內(nèi)容是否更改
這篇文章主要介紹了Android 使用ContentObserver監(jiān)聽數(shù)據(jù)庫內(nèi)容是否更改的相關(guān)資料,ContentObserver內(nèi)容觀察者,目的是觀察(捕捉)特定Uri引起的數(shù)據(jù)庫的變化,需要的朋友可以參考下2017-08-08Android GSYVideoPlayer視頻播放器功能的實現(xiàn)
這篇文章主要介紹了Android GSYVideoPlayer視頻播放器功能的實現(xiàn),本文通過實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-03-03Android編程實現(xiàn)TextView字體顏色設(shè)置的方法小結(jié)
這篇文章主要介紹了Android編程實現(xiàn)TextView字體顏色設(shè)置的方法,結(jié)合實例形式總結(jié)分析了Android針對TextView字體顏色設(shè)置的相關(guān)步驟與注意事項,具有一定參考借鑒價值,需要的朋友可以參考下2015-12-12Android實現(xiàn)創(chuàng)意LoadingView動畫效果
這篇文章主要介紹了Android實現(xiàn)創(chuàng)意LoadingView動畫效果的相關(guān)資料,需要的朋友可以參考下2016-02-02淺談Android為RecyclerView增加監(jiān)聽以及數(shù)據(jù)混亂的小坑
下面小編就為大家?guī)硪黄獪\談Android為RecyclerView增加監(jiān)聽以及數(shù)據(jù)混亂的小坑。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-04-04解析Android開發(fā)中多點觸摸的實現(xiàn)方法
多點觸摸(MultiTouch),指的是允許計算機用戶同時通過多個手指來控制圖形界面的一種技術(shù)。與多點觸摸技術(shù)相對應(yīng)的就是單點觸摸,單點觸摸的設(shè)備已經(jīng)有很多年了,小尺寸的有觸摸式的手機,大尺寸的最常見的就是銀行里的ATM機和排隊查詢機等等2013-05-05