キーボードを作成しました。ユーザーが数字を入力すると、特定のEditText
に送信されますが、ユーザーが「完了」キーをクリックすると、setOnEditorActionListener
にはなりません(キーボードは閉じます)。Android OnEditorActionListener()actionIdは、完了をクリックすると0を返します。
これは私のコードです:私はAndroidのソフトキーボードその作業罰金を介して実行すると
final EditText txtQty = new EditText(this);
txtQty.setHeight(1);
txtQty.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 42));
txtQty.setInputType(InputType.TYPE_CLASS_PHONE);
txtQty.setImeOptions(EditorInfo.IME_ACTION_DONE);
txtQty.setSelectAllOnFocus(true);
txtQty.setTextSize(9);
txtQty.setVisibility(View.VISIBLE);
txtQty.setHint("0.0");
txtQty.setHighlightColor(R.color.green);
tr.addView(txtQty);
txtQty.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
Log.i("KeyBoard" ,"Inside the Edit Text");
if (actionId == EditorInfo.IME_ACTION_DONE ||actionId == EditorInfo.IME_ACTION_NEXT) { ......}
は、ここでは、actionId = 0
とEditorInfo.IME_ACTION_NEXT = 5
を与えます。ここで
txtQty.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
Log.i("KeyBoard" ,"Inside the Edit Text");
Log.i("---EditorInfo.IME_ACTION_NEXT---" , EditorInfo.IME_ACTION_NEXT);
Log.i("---actionId---" , actionId);
Log.i("---event---" , event);
Log.i("---EditorInfo.IME_ACTION_DONE---" , EditorInfo.IME_ACTION_DONE);
それはEditorInfo.IME_ACTION_NEXT = 5, actionId = 5
と
EditorInfo.IME_ACTION_DONE = 6, actionId = 6
を与えている。しかし、私は私のソフトキーボードを介して実行する際には、EditorInfo.IME_ACTION_NEXT = 5, actionId = 0
とEditorInfo.IME_ACTION_DONE = 6, actionId = 0
を与えます。
なぜ私のソフトキーボードでactionId
の値を取らなかったのですか?