KeyboardView.OnKeyboardActionListener.onRelease()
SDK belgelerine göre, "Tekrar eden tuşlar için, bu yalnızca bir kez çağrılır". Ancak, Android Softkeyboard örneğiyle 'a' anahtarını true olarak ayarlanıp ayarlamam ve onPress()
, , onKey()
ve onRelease()
yöntem çağrılarını günlüğe kaydetmem gerekirse, yinelemeyi beklediğim gibi alıyorum ancak tek bir bas/tekrarla/bırakma dizisi için aşağıdaki günlüğü gözlemliyorum. : dokunmatik cihaz piyasaya sürüldükten ne zamanNeden her key repetition sonra android KeyboardView.OnKeyboardActionListener.onRelease() denir?
I/SoftKeyboard(31467): onPress: 97
I/SoftKeyboard(31467): onKey: 97
I/SoftKeyboard(31467): onRelease: 97
I/SoftKeyboard(31467): onKey: 97
I/SoftKeyboard(31467): onRelease: 97
I/SoftKeyboard(31467): onKey: 97
I/SoftKeyboard(31467): onRelease: 97
I/SoftKeyboard(31467): onKey: 97
I/SoftKeyboard(31467): onRelease: 97
I/SoftKeyboard(31467): onKey: 97
I/SoftKeyboard(31467): onRelease: 97
nasıl tam olarak belirleyebilir? Teşekkürler, ben OP değilim rağmen D.
DÜZENLEME (Paul Boddington 30/07/2015 tarafından Edit)
ben de sorunu gösteren eksiksiz bir örnek dahil etmek istedik.
MyActivity
public class MyActivity extends Activity {
private static final String TAG = "MyActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
KeyboardView keyboardView = (KeyboardView) findViewById(R.id.keyboard_view);
keyboardView.setKeyboard(new Keyboard(this, R.xml.keyboard));
keyboardView.setOnKeyboardActionListener(new KeyboardView.OnKeyboardActionListener() {
@Override
public void onPress(int i) {
Log.i(TAG, "onPress: " + i);
}
@Override
public void onKey(int i, int[] ints) {
Log.i(TAG, "onKey: " + i);
}
@Override
public void onRelease(int i) {
Log.i(TAG, "onRelease: " + i);
}
@Override public void onText(CharSequence charSequence) {}
@Override public void swipeLeft() {}
@Override public void swipeRight() {}
@Override public void swipeDown() {}
@Override public void swipeUp() {}
});
}
}
keyboard.xml
:
<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android">
android:layout_height="wrap_content"
android:layout_width="match_parent"
>
<Row
android:keyWidth="25%p"
android:keyHeight="60dp">
<Key android:codes="0" android:keyLabel="0" android:isRepeatable="true"/>
<Key android:codes="1" android:keyLabel="1" />
<Key android:codes="2" android:keyLabel="2" />
<Key android:codes="3" android:keyLabel="3" />
</Row>
</Keyboard>
activity_my.xml
:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.inputmethodservice.KeyboardView
android:id="@+id/keyboard_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
/>
</LinearLayout>
Sanırım anahtarınız tekrarlanan değil ... – Marcus
Evet, öyle. Orijinal yazıyı açıklığa kavuşturdum. – davhoo
Stok Android klavyesini kullanıyor musunuz? – Zerp