Cannot resolve symbol KeyEventCompat(android.support.v4.view.KeyEventCompat找不到)

Posted 黑帅-quan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cannot resolve symbol KeyEventCompat(android.support.v4.view.KeyEventCompat找不到)相关的知识,希望对你有一定的参考价值。

Cannot resolve symbol KeyEventCompat(android.support.v4.view.KeyEventCompat找不到)
解决方案
KeyEventCompat类(我项目中用它的hasNoModifiers方法)最后查看源码 才知道这个hasNoModifiers方法已经被KeyEvent实现了。 贴出源码:

public boolean executeKeyEvent(KeyEvent event) {
//报错地方
                    // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
                    // before Android 3.0. Ignore the tab key on those devices.
//                  if (KeyEventCompat.hasNoModifiers(event)) {
//                      handled = arrowScroll(FOCUS_FORWARD);
//                  } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
//                      handled = arrowScroll(FOCUS_BACKWARD);
//                  }


//                  http://blog.csdn.net/lrpshuai/article/details/78392872

//正确代码
                    if (event.hasNoModifiers()) {
                        handled = arrowScroll(FOCUS_FORWARD);
                    } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
                        handled = arrowScroll(FOCUS_BACKWARD);
                    }
}


以上是关于Cannot resolve symbol KeyEventCompat(android.support.v4.view.KeyEventCompat找不到)的主要内容,如果未能解决你的问题,请参考以下文章

Java 报错cannot resolve symbol String Utils怎么解决?

Cannot resolve symbol ‘c:forEach‘;

Cannot resolve symbol 'SpringBootApp

cannot resolve symbol AppCompatActivity 心得

Reshaper cannot resolve symbol

IntelliJ IDEA提示Cannot resolve symbol