问题描述
我想更改模板,以便新活动使用AppCompatActivity
而不是已贬值的ActionBarActivity
I would like to change the template so that the new activity uses AppCompatActivity
instead of the depreciated ActionBarActivity
我找到了sdk\tools\templates\activities\BlankActivity\root\src\app_package\SimpleActivity.java.ftl
,并在制作了备份副本后更改了
I found sdk\tools\templates\activities\BlankActivity\root\src\app_package\SimpleActivity.java.ftl
and after making a backup copy I changed
import <#if appCompat>android.support.v7.app.ActionBarActivity<#else>android.app.Activity</#if>;
到
import <#if appCompat>import android.support.v7.app.AppCompatActivity<#else>android.app.Activity</#if>;
和
public class ${activityClass} extends ${(appCompat)?string('ActionBar','')}Activity {
到
public class ${activityClass} extends ${(appCompat)?string('AppCompat','')}Activity {
但是当我创建一个新活动时,它仍然使用ActionBarActivity.
but when I create a new activity it still uses ActionBarActivity.
推荐答案
我只是更改两个位置:
1.import< #if appCompat> android.support.v7.app. AppCompatActivity < #else> android.app.Activity;
1.import <#if appCompat>android.support.v7.app.AppCompatActivity<#else>android.app.Activity;
2.public类$ {activityClass}扩展了$ {(appCompat)?string(' AppCompat ','')}活动{
2.public class ${activityClass} extends ${(appCompat)?string('AppCompat','')}Activity {
这对我有用!
我看到您的代码,您的第一次编辑还有一个导入"字符串. -_- ||||
I see you code, your first edit has one more "import" string. -_-|||
顺便说一下,我在 Android-Studio文件夹下编辑SimpleActivity.java.ftl
:"X:\xxxx\android-studio\plugins\android\lib\templates\activities\BlankActivity\root\src\app_package"
By the way, I edit SimpleActivity.java.ftl
under Android-Studio folder:"X:\xxxx\android-studio\plugins\android\lib\templates\activities\BlankActivity\root\src\app_package"
这篇关于如何更改Android Studio用于创建空白活动的模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!