I want to use KeyEvent example KEYCODE_0 Link in button onClick
<Button
android:id="@+id/Btnequal_id"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_weight="1"
android:onClick="0x00000007"
android:text="=" />
get instance of your EditText on which you wanna apply keyEvent listener,then setOnKeyListner on your edittext like below.
mPinBox4 = (EditText) findViewById(R.id.pinVerifyBox4);
mPinBox4.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode==KeyEvent.KEYCODE_0){
//excute what ever you want when KEYCODE_0 is pressed
}
return false;
}
});
You can up vote my answer if it works for you.Thanks
onKeyEvent can be applied on EditText.I think you are asking wrong question. Please clear me if ,Iam wrong.
User contributions licensed under CC BY-SA 3.0