SORU
5 Ocak 2010, Salı


Android EditText İmeOptions "Bitti" bitirmek yazmaya parça

Bu olay üzerine tıklayın kullanıcı klavyede bitti düğmesini görüntülemek böylece aşağıdaki özellik ayarı nerede olduğumu edittext alanı yaşıyorum.

editText.setImeOptions(EditorInfo.IME_ACTION_DONE);

Kullanıcı(bitiş) yazma radyo düğmesi durumunu değiştirmek istiyorum ekran klavyesi üzerinde bitti düğmesini tıklattığında, nasıl ekran klavye darbe olduğunda bitti düğmesine izleyebilir miyim ?

enter image description here

CEVAP
20 Mart 2011, Pazar


Yukarı Roberts ve chirags cevaplar kombinasyonu ile sona erdi:

((EditText)findViewById(R.id.search_field)).setOnEditorActionListener(
        new EditText.OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_SEARCH ||
                actionId == EditorInfo.IME_ACTION_DONE ||
                event.getAction() == KeyEvent.ACTION_DOWN &&
                event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
            onSearchAction(v);
            return true;
        }
        return false;
    }
});

Güncelleme: Yukarıdaki kodu birkaç kez geri iki kez aktive olur. Bunun yerine Google'dan buldum aşağıdaki kodu için sohbet istemcileri tercih ettik:

public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (event != null) {
        // if shift key is down, then we want to insert the '\n' char in the TextView;
        // otherwise, the default action is to send the message.
        if (!event.isShiftPressed()) {
            if (isPreparedForSending()) {
                confirmSendMessageIfNeeded();
            }
            return true;
        }
        return false;
    }

    if (isPreparedForSending()) {
        confirmSendMessageIfNeeded();
    }
    return true;
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Alexey - servant of Christ

    Alexey - ser

    15 EYLÜL 2007
  • paulandstorm

    paulandstorm

    4 EYLÜL 2006
  • wafflepwn

    wafflepwn

    14 AĞUSTOS 2008