gpt4 book ai didi

android - 启动应用程序时关闭软键盘

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

<分区>

我有一个简单的应用程序,有 2 个编辑和一个按钮,问题是当我开始运行我的应用程序时,软键盘自动出现,而我没有做任何事情。我想当我点击 Edittext 时,会出现软键盘?谢谢大家

主 Activity .xml

<EditText
android:id="@+id/username"
android:hint="Email/Phone"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/password"
android:hint="Password"
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/btn_login"
android:text="Login"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

我已经阅读了一些帖子并做了这些事情,但它们只有在我点击按钮时才有效:

InputMethodManager imm;
imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(username.getWindowToken(),0);

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