Android Settings 取消全选效果改为直接选中选项
Posted 王睿丶
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android Settings 取消全选效果改为直接选中选项相关的知识,希望对你有一定的参考价值。
思路:
当获取到上下键值时,判断当前界面如果是设置主界面,就让它不执行全选代码
路径:frameworks/base/core/java/android/view/ViewRootImpl.java
if (direction!=33 || (direction == 33 && (!"com.android.settings.homepage.SettingsHomepageActivity".equals(cn.getClassName()))))
private boolean performFocusNavigation(KeyEvent event)
if (direction != 0)
View focused = mView.findFocus();
if (focused != null)
View v = focused.focusSearch(direction);
if (v != null && v != focused)
// do the math the get the interesting rect
// of previous focused into the coord system of
// newly focused view
focused.getFocusedRect(mTempRect);
if (mView instanceof ViewGroup)
((ViewGroup) mView).offsetDescendantRectToMyCoords(
focused, mTempRect);
((ViewGroup) mView).offsetRectIntoDescendantCoords(
v, mTempRect);
+ //wangrui On the home page of the settings, cancel the selection and select the first level directory instead
+ am = (android.app.ActivityManager) mContext.getSystemService(ACTIVITY_SERVICE);
+ cn = am.getRunningTasks(1).get(0).topActivity;
+ if (direction!=33 || (direction == 33 && (!"com.android.settings.homepage.SettingsHomepageActivity".equals(cn.getClassName()))))
+ if (v.requestFocus(direction, mTempRect))
+ playSoundEffect(SoundEffectConstants
+ .getContantForFocusDirection(direction));
+ return true;
+
+
Settings 开发系列:
Android Settings 去除振动功能
Android Settings 去除自动旋转屏幕
Android Settings 使设置主界面可以被键盘上下键所选中
Android Settings 取消全选效果改为直接选中选项
以上是关于Android Settings 取消全选效果改为直接选中选项的主要内容,如果未能解决你的问题,请参考以下文章
Android开发CheckBox控件,全选,反选,取消全选