1. 程式人生 > >Android studio 新建工程activity預設繼承AppCompatActivity

Android studio 新建工程activity預設繼承AppCompatActivity

Activity is the baseline. Every activity inherits from Activity, directly or indirectly.

FragmentActivity is for use with the backport of fragments found in the support-v4 and support-v13 libraries. The native implementation of fragments was added in API Level 11, which is higher than your proposed minSdkVersion values. The only reason why you would need to consider FragmentActivity specifically is if you want to use nested fragments (a fragment holding another fragment), as that was not supported in native fragments until API Level 17.

AppCompatActivity is from the appcompat-v7 library. Principally, this offers a backport of the action bar. Since the native action bar was added in API Level 11, you do not need AppCompatActivity for that. However, current versions of appcompat-v7 also add a limited backport of the Material Design aesthetic, in terms of the action bar and various widgets. There are pros and cons of using appcompat-v7, well beyond the scope of this specific Stack Overflow answer.

ActionBarActivity is the old name of the base activity from appcompat-v7. For various reasons, they wanted to change the name. Unless some third-party library you are using insists upon an ActionBarActivity, you should prefer AppCompatActivity over ActionBarActivity.

So, given your minSdkVersion in the 15-16 range:

  • If you want the backported Material Design look, use AppCompatActivity

  • If not, but you want nested fragments, use FragmentActivity

  • If not, use Activity

相關推薦

Android studio 新建工程activity預設繼承AppCompatActivity

Activity is the baseline. Every activity inherits from Activity, directly or indirectly. FragmentActivity is for use with the backport of fragments found

Android studio新建工程報錯:Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict wit

報錯: Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependency 'com.android.support:support-annotations' in pr

Android Studio 新建工程出現 Waiting for build to finishing

解決方案: Ctrl + Shift + A 快捷鍵,輸入 Sync Project with Gradle Files 點選等待 Sync 完成即可, 如果報 Gradle sync failed: Cause: error in opening zip fi

android studio 新建工程遇到問題 沒有R檔案,build失敗

剛開始接觸 android studio ,新建一個工程,寫了一個layout.xml 檢視,沒有R檔案 ,build 失敗。 原來是build gradle(Mouble:app)檔案配置錯誤造成的

Android Studio 新建Andorid工程報錯: Conflict with dependency 'com.android.support:support-annotations'

bug 方法 andro erro failed resolv and div tails 新建Android工程報錯: Error:Execution failed for task ‘:app:preDebugAndroidTestBuild‘. > Confl

Android studio 新建一個空白工程提示:Conflict with dependency 'com.android.support:support-annotations' in proj

Android studio 新建一個空白工程提示:Conflict with dependency 'com.android.support:support-annotations' in project ':app'.     Error:Execution fa

Android Studio 新建編譯 Java 工程

1、新建New Module 2、選擇java Library 3、編輯lib name 、class name 4、新增Main函式入口 5、選擇Run -->Edit Configurations 6、選擇+-->Application 7、選

Android之無法隱藏標題欄 繼承AppCompatActivityActivity無法隱藏標題欄解決方案

問題描述: 繼承了AppCompatActivity的Activity無法通過呼叫requestWindowFeature(Window.FEATURE_NO_TITLE)來隱藏標題欄。 publicclass MainActivity extends AppCo

指定Android Studio編譯工程時的源文件編碼

javac Coding 設置 odin images utf8編碼 androi mage nco 統一設置為UTF8編碼在工程的根目錄下的build.gradle文件中,添加定義。tasks. withType(JavaCompile) { options.enc

Android Studio更改工程名異常解決方案 :can't rename root module

包括 extern ext 相關 文件名 post roo 手動 修改文件 在修改Android Studio 中 project的名字時 ,提示 “can’t rename root module”。 這是因為Android S

[轉載]解決Android studio新建項目慢的問題

jsb nbsp 導入 tails prope mark git sdn CM 原文地址為:https://blog.csdn.net/easion_zms/article/details/73181402 Android Studio 好處很多,但是當從github上或

android studio 新建一個專案,卻出現Design editor is unavailable until after a successful project sync

android studio 新建一個專案,卻出現Design editor is unavailable until after a successful project sync waiting for build to finish 點選工具欄File -> sync proje

Android Studio新建和匯入專案報錯, Read timed out,Error:SSL peer shut down incorrectly

建立新專案時出現 Android Studio Read timed out Error:SSL peer shut down incorrectly 解決辦法:在project的gradle中加入以下程式碼 順序很重要 google() mavenCen

Android Studio新建類的時候自動生成註釋資訊

 點選選單欄的File——>Settings 開啟Settings選單 ,如圖: 2. 找到Editor選項,點選Editor下的File and Code Templates選項,在右側介面中找到Includes,選中File Header 就可以編輯註釋自己想要的模

android studio 新建或者匯入專案時緩慢或卡死的問題

先說一下碰到的問題,最近要換一個電腦開發,電腦上環境都已經配好就直接down下來專案匯入,發現在Building的時特別慢,之前從github上下載的專案也會出現這種情況,等的是心力交瘁。 為了解決這個問題花了將近一天的時間,特將其記錄下來,希望對碰到這個問題的朋友有所幫助。 注: A

更改Android studio,AVD的預設路徑

由於才開始學習Android,所以本博主對AndroidStudio這款軟體一竅不通,模擬器(AVD)的大小是按G為單位增長的,預設下載路徑偏偏又是小得可憐的C盤,所以是時候治治這個問題了。在網上找尋辦法,終於解決了這個問題,接下來會展示本博主親測有效的方法。

完美解決 Android Studio 匯入工程, 成功編譯, 但是程式碼提示錯誤

在 github 上下載了開源的程式碼, 使用 Android Studio 匯入工程後, 執行編譯成功, 但是開啟程式碼檔案時, 發現裡面全是紅色提示, 都是些什麼類找不到, 無法匯入包。。。搞得我一頭霧水, github 上求助, Google 上搜索,

Android Studio工程、多工程級聯依賴下的aar的引用

Android Studio 多工程級聯依賴下的aar的引用 背景: application A 依賴 library B library B 依賴 library C library C 引用a

Android Studio新建內建模擬器

這是一篇很簡單的教程,基本步驟與Eclipse大體相同,留給後來者參閱 首先,開啟Android Studio,在主介面中找到模擬器管理按鈕,如下: 開啟後,若沒有新增過模擬器,會是以下介面: 點選:Create Virtual Device,進入新建模擬器介面: 簡

解決Android studio 新建專案關於com.android.support:support-annotations的依賴衝突

Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependency 'com.android.support:support-annotations' i