android 14 设置菜单中增加返回操作

修改点packages/apps/Settings 

diff --git a/res/drawable/ic_settings_backkey.xml b/res/drawable/ic_settings_backkey.xml
new file mode 100644
index 0000000000..f5a2f00f21
--- /dev/null
+++ b/res/drawable/ic_settings_backkey.xml
@@ -0,0 +1,25 @@
+<!--
+    Copyright (C) 2016 The Android Open Source Project
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24.0dp"
+        android:height="24.0dp"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0"
+        android:tint="?android:attr/colorControlNormal">
+    <path
+       android:fillColor="#FF000000"
+        android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
+</vector>
diff --git a/res/xml/top_level_settings.xml b/res/xml/top_level_settings.xml
old mode 100644
new mode 100755
index e35a404dc2..1bf17b077d
--- a/res/xml/top_level_settings.xml
+++ b/res/xml/top_level_settings.xml
@@ -20,6 +20,13 @@
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="top_level_settings">

+    <Preference
+        android:key="level_back_key"
+        android:title="@string/wizard_back"
+        android:summary="@string/wizard_back"
+        android:icon="@drawable/ic_settings_backkey"
+        android:order="-160"/>
+
     <com.android.settings.widget.HomepagePreference
         android:fragment="com.android.settings.network.NetworkDashboardFragment"
         android:icon="@drawable/ic_settings_wireless"
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index b7a04575e9..91ebedbdfa 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -252,6 +252,10 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
     public boolean onPreferenceTreeClick(Preference preference) {
         final Collection<List<AbstractPreferenceController>> controllers =
                 mPreferenceControllers.values();
+        if(preference.getKey().equals("level_back_key")){
+            Log.e(TAG, "click level_back_key ....");
+            finish();
+        }
         for (List<AbstractPreferenceController> controllerList : controllers) {
             for (AbstractPreferenceController controller : controllerList) {
                 if (controller.handlePreferenceTreeClick(preference)) {

如上所示,设置界面新增一个返回菜单

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值