Change key icon keyboard: Drawable return int?

  • Replies:1
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Nov 30, 2015 8:04:32 PM via Website

I'm trying to change a key icon on press in run time:

public void onPress(int primaryCode) {
    Keyboard currentKeyboard = KbView.getKeyboard();
    List<Keyboard.Key> keys = currentKeyboard.getKeys();
    keys.get(primaryCode).label = null;
    keys.get(primaryCode).icon = R.drawable.image;

However, the last line says:

Incompatible types. 
Found: int

If I use instead: keys.get(ponto).icon = getResources().getDrawable(R.drawable.image); says that getDrawable(int) is deprecated. (It works, but when I press a key, change the icon of other key)

(I'm using API level 8)

  • Forum posts: 105

Jan 11, 2016 1:14:46 PM via Website

Hey there, did it worked finally? I think the code seems perfect & it should run without any stuck.