内容简介:从源码中看到Settings继承SettingsActivity,而SettingsActivity继承SettingsDrawerActivity,在SettingsDrawerActivity的onCreate方法中,我们看到调用了getDashboardCategories方法,代码:getDashboardCategories();//获取设置项列表setActionBar(toolbar);
从源码中看到Settings继承SettingsActivity,而SettingsActivity继承SettingsDrawerActivity,在SettingsDrawerActivity的onCreate方法中,我们看到调用了getDashboardCategories方法,代码:
getDashboardCategories();//获取设置项列表
setActionBar(toolbar);
mDrawerAdapter = new SettingsDrawerAdapter(this);
ListView listView = (ListView) findViewById(R.id.left_drawer);
listView.setAdapter(mDrawerAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(Android.widget.AdapterView<?> parent, View view, int position,
long id) {
onTileClicked(mDrawerAdapter.getTile(position));
}
});
跟进到该方法的具体实现:
public List<DashboardCategory> getDashboardCategories() {
if (sDashboardCategories == null) {
sTileCache = new HashMap<>();
sConfigTracker = new InterestingConfigChanges();
// Apply initial current config.
boolean newC =sConfigTracker.applyNewConfig(getResources());
Log.d(TAG, "newC = " + newC);
sDashboardCategories = TileUtils.getCategories(this, sTileCache);//重点在这里
}
return sDashboardCategories;
}
跟进到getCategories方法:
private static final String EXTRA_SETTINGS_ACTION =
"com.android.settings.action.EXTRA_SETTINGS";
/**
* Same as #EXTRA_SETTINGS_ACTION but used for the platform Settings activities.
*/
private static final String SETTINGS_ACTION =
"com.android.settings.action.SETTINGS";
private static final String OPERATOR_SETTINGS =
"com.android.settings.OPERATOR_APPLICATION_SETTING";
private static final String OPERATOR_DEFAULT_CATEGORY =
"com.android.settings.category.wireless";
private static final String MANUFACTURER_SETTINGS =
"com.android.settings.MANUFACTURER_APPLICATION_SETTING";
private static final String MANUFACTURER_DEFAULT_CATEGORY =
"com.android.settings.category.device";
//以上是TileUtils.java定义的常量
public static List<DashboardCategory> getCategories(Context context,
HashMap<Pair<String, String>, Tile> cache) {
//......省略
for (UserHandle user : userManager.getUserProfiles()) {
// TODO: Needs much optimization, too many PM queries going on here.
if (user.getIdentifier() == ActivityManager.getCurrentUser()) {
// Only add Settings for this user.
getTilesForAction(context, user, SETTINGS_ACTION, cache, null, tiles, true);
getTilesForAction(context, user, OPERATOR_SETTINGS, cache,
OPERATOR_DEFAULT_CATEGORY, tiles, false);
getTilesForAction(context, user, MANUFACTURER_SETTINGS, cache,
MANUFACTURER_DEFAULT_CATEGORY, tiles, false);
}
if (setup) {
getTilesForAction(context, user, EXTRA_SETTINGS_ACTION, cache, null, tiles, false);
}
}
//......省略
return categories;
}
到这里我们就可以看得到,这是根据AndroidManifest.xml对activity及fragement的定义来划分设置项分类的。我们再看一下AndroidManifest.xml对各个activity及fragment的定义,拿个简单的来看看:
<activity android:name="Settings$AppMemoryUsageActivity"
android:label="@string/app_list_memory_use"
android:icon="@drawable/ic_settings_memory">
<intent-filter>
<action android:name="android.settings.APP_MEMORY_USAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!-- <meta-data android:name="com.android.settings.category"
android:value="com.android.settings.category.device" /> -->
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.applications.ProcessStatsUi" />
</activity>
这里我们只要前设置项分类去掉就能够删除掉这一设置项<meta-data android:name="com.android.settings.category" android:value="com.android.settings.category.device" />,同里如果我们要增加设置项,只要按不同的分类设置参数就行了。
Linux公社的RSS地址 : https://www.linuxidc.com/rssFeed.aspx
本文永久更新链接地址: https://www.linuxidc.com/Linux/2018-09/1544664.htm
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- MySQL删除操作其实是假删除
- C++拾趣——STL容器的插入、删除、遍历和查找操作性能对比(Windows VirtualStudio)——删除
- 我用 Python 找出了删除我微信的所有人并将他们自动化删除了
- C++拾趣——STL容器的插入、删除、遍历和查找操作性能对比(Windows VirtualStudio)——遍历和删除
- ruby-on-rails-4 – Rails 4:如何从数据库中删除或删除(连接)表表?
- 删除并恢复
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Java Concurrency in Practice
Brian Goetz、Tim Peierls、Joshua Bloch、Joseph Bowbeer、David Holmes、Doug Lea / Addison-Wesley Professional / 2006-5-19 / USD 59.99
This book covers: Basic concepts of concurrency and thread safety Techniques for building and composing thread-safe classes Using the concurrency building blocks in java.util.concurrent Pe......一起来看看 《Java Concurrency in Practice》 这本书的介绍吧!