Frage

I have got custom keyboard for Arabic language and normal English keyboard for quick search box searching from my Sqlite database. English keyboard works fine. But when Arabic keyword pop-ups, I can NOT type into Edit-Text ...

My code:

 public class MainActivity extends FragmentActivity {

CustomKeyboard mCustomKeyboard;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mCustomKeyboard = new CustomKeyboard(this, R.id.keyboardview,
            R.xml.hexkbd);

    View button = findViewById(R.id.btn_search_en);
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            onSearchRequested();
        }
    });

    View button1 = findViewById(R.id.btn_search_ar);
    button1.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            toggleKeyboardVisibility();
        }
    });
}

private void toggleKeyboardVisibility() {
    KeyboardView mCustomKeyboard = (KeyboardView) findViewById(R.id.keyboardview);
    int visibility = mCustomKeyboard.getVisibility();
    switch (visibility) {
    case View.VISIBLE:
        mCustomKeyboard.setVisibility(View.INVISIBLE);
        break;
    case View.GONE:
    case View.INVISIBLE:
        mCustomKeyboard.setVisibility(View.VISIBLE);
        break;
    }
}

@Override
public void onBackPressed() {
    // NOTE Trap the back key: when the CustomKeyboard is still visible hide
    // it, only when it is invisible, finish activity
    if (mCustomKeyboard.isCustomKeyboardVisible())
        mCustomKeyboard.hideCustomKeyboard();
    else
        this.finish();
}
}
War es hilfreich?

Lösung

You need to register every EditText that you want to use the keyboard on like:

mCustomKeyboard = new CustomKeyboard(this, R.id.keyboardview,
            R.xml.hexkbd);

// register the edittext
mCustomKeyboard.registerEditText(R.id.edittext);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top