小编Tua*_*uan的帖子

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

我有一个简单的应用程序,有 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)

keyboard android

6
推荐指数
1
解决办法
148
查看次数

将结构化平面数组转换为树对象

我的脚本有一个未解决的问题,我有FlatObj数组和一些规则,我需要将转换器函数写入TreeObj

规则:

  • 相邻较高深度将是相邻较低深度的子级
  • “ROOT”将是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)

javascript typescript

0
推荐指数
1
解决办法
48
查看次数

标签 统计

android ×1

javascript ×1

keyboard ×1

typescript ×1