gpt4 book ai didi

android - 控制 Ok SoftKeyboard 按钮 Android

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:24:26 25 4
gpt4 key购买 nike

当我点击下面显示的编辑文本时,我在软安卓键盘上设置了一个确定键:

 <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" />

当键盘出现时,我希望用户在点击确定按钮时做一些事情。但是我怎样才能覆盖键盘上的确定按钮来做我想做的事

最佳答案

您需要实现 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 */
}
}
});

关于android - 控制 Ok SoftKeyboard 按钮 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17469499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com