gpt4 book ai didi

android - 保持键盘的 android 软件显示

转载 作者:搜寻专家 更新时间:2023-11-01 08:43:44 25 4
gpt4 key购买 nike

我在软键盘上添加了“Go”按钮,只要我按下它,键盘就会隐藏起来。如何保持显示?使用此代码显示它不起作用。谢谢

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId== EditorInfo.IME_ACTION_GO){
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
}

return false;
}

最佳答案

我已经为你编辑了答案,如果你错过了 setSingleLine(true) 整个东西将无法工作..我以为你已经添加了,但你可能没有 试试这个兄弟:

    et1.setHint("testing");
et1.setImeActionLabel("Go", EditorInfo.IME_ACTION_GO);
et1.setSingleLine(true);


et1.setOnEditorActionListener(new OnEditorActionListener() {

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

if(actionId== EditorInfo.IME_ACTION_GO){


InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(et1, InputMethodManager.SHOW_FORCED);
return true;
}

else
return false;
}
} );

关于android - 保持键盘的 android 软件显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30387288/

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