Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KeyEventCompat not supported at build

My project is currently using but seems I have moved to api level 26 - revision 26.0.2, I am struggling to find the symbol KeyEventCompat

import android.support.v4.view.KeyEventCompat; 

I try to figure out using v7 but it's not working. Any idea on how to make it works.

Example of use:

case KeyEvent.KEYCODE_TAB:     if (KeyEventCompat.hasNoModifiers(event)) {         handled = arrowScroll(FOCUS_FORWARD);     } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {         handled = arrowScroll(FOCUS_BACKWARD);     }     break; 

Any idea on how to make it works.

Thanks

like image 428
Seb Avatar asked Apr 30 '18 20:04

Seb


1 Answers

change this

if (KeyEventCompat.hasNoModifiers(event)) {     handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {     handled = arrowScroll(FOCUS_BACKWARD); } 

to

if (event.hasNoModifiers()) {     handled = arrowScroll(FOCUS_FORWARD); } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {     handled = arrowScroll(FOCUS_BACKWARD); } 

KeyEventCompat class was deprecated in API level 26.0.0

like image 164
Madhur Avatar answered Sep 30 '22 03:09

Madhur