栏目分类:
子分类:
返回
终身学习网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
终身学习网 > IT > 软件开发 > 后端开发 > Java

Android 11.0 修复在Settings首页,按键盘方向键不会全部选中而是选中单个选项

Java 更新时间:发布时间: 百科书网 趣学号

思路:
当获取到上下键值时,判断当前界面如果是设置主界面,就让它不执行全选代码

路径: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;
+                            }
+                        }

                    }
        }
转载请注明:文章转载自 www.051e.com
本文地址:http://www.051e.com/it/959744.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 ©2023-2025 051e.com

ICP备案号:京ICP备12030808号