我有一个简单的应用程序,有 2 个编辑和一个按钮,问题是当我开始运行我的应用程序时,软键盘会自动出现,而我没有执行任何操作。我想当我点击Edittext时,会出现软键盘?谢谢你们
MainActivity.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"/>
Run Code Online (Sandbox Code Playgroud)
我读过一些帖子并做了这些事情,但它们只有在我单击按钮时才起作用:
InputMethodManager imm;
imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(username.getWindowToken(),0);
Run Code Online (Sandbox Code Playgroud) 我的脚本有一个未解决的问题,我有FlatObj数组和一些规则,我需要将转换器函数写入TreeObj。
规则:
interface FlatObj {
id: String;
depth: number;
}
interface TreeObj {
id: String;
children?: TreeObj[];
}
const data: FlatObj[] = [
{
id: "ROOT",
depth: 0
},
{
id: "G1",
depth: 1
},
{
id: "G2",
depth: 1
},
{
id: "G2-1",
depth: 2
},
{
id: "G2-2",
depth: 2
},
{
id: "G2-2-1",
depth: 3
},
{
id: "G3",
depth: 1
}
];
const converter …Run Code Online (Sandbox Code Playgroud)