【问题标题】:Controlling Ok SoftKeyboard buttons Android控制 Ok SoftKeyboard 按钮 Android
【发布时间】:2013-07-04 11:47:20
【问题描述】:

当我点击如下所示的编辑文本时,我在软 android 键盘上设置了一个 Ok 键:

 <EditText
            android:id="@+id/rlMP3SeekContainer"
            android:layout_width="0dp"
            android:layout_height="40dp"
            android:layout_weight="1"
            android:background="@drawable/text_rougea"
            android:singleLine="true" 
            android:imeOptions="actionDone"
            android:ems="10"
            android:hint="@string/hint_deezer_search"
            android:paddingLeft="@dimen/eight_dp"
            android:paddingRight="@dimen/eight_dp"
            android:textColor="@color/black"
            android:textColorHint="@color/gray_text"
            android:textSize="@dimen/twelve_sp" />

当键盘出现时,我希望用户在单击确定按钮时执行某些操作。但是我怎样才能覆盖键盘上的 ok 按钮来做任何我想做的事情

【问题讨论】:

    标签: android android-keypad


    【解决方案1】:

    你需要实现 OnEditorActionListener:

    yourEditText.setOnEditorActionListener(
            new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
              if (actionId == EditorInfo.IME_ACTION_DONE) {
                /* your code here */
              }
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-06
      • 2010-11-18
      • 1970-01-01
      • 1970-01-01
      • 2014-07-12
      相关资源
      最近更新 更多