gpt4 book ai didi

android - 如何设置edittext以显示搜索按钮或键盘上的输入按钮?

转载 作者:IT王子 更新时间:2023-10-28 23:41:41 33 4
gpt4 key购买 nike

如何设置 EditText 在键盘上显示搜索按钮或输入按钮?

最佳答案

在您的布局中将输入法设置为“搜索”选项

 <EditText 
android:imeOptions="actionSearch"
android:inputType="text"/>

在java代码中使用

editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
performSearch();
return true;
}
return false;
}
});

关于android - 如何设置edittext以显示搜索按钮或键盘上的输入按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6529485/

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