Android 编辑文本不接受‘;编号’;DialogFragment中的键盘输入

Android 编辑文本不接受‘;编号’;DialogFragment中的键盘输入,android,Android,我使用EditText以数字(频率)的形式捕获用户输入。我在DialogFragment中有一个EditText。但正如您在下面的gif链接中所看到的,带有“android:inputType=number”的EditText不接受softkeybard的数字输入。请帮忙 以下是布局文件的代码- <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.

我使用EditText以数字(频率)的形式捕获用户输入。我在DialogFragment中有一个EditText。但正如您在下面的gif链接中所看到的,带有“android:inputType=number”的EditText不接受softkeybard的数字输入。请帮忙

以下是布局文件的代码-

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@color/colorPrimary"
        android:gravity="center"
        android:text="@string/add_dialog_title"
        android:textColor="@android:color/white"
        android:textSize="22sp" />

    <TextView
        android:id="@+id/text_view_name"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="16dp"
        android:layout_weight="1"
        android:inputType="textCapWords"
        android:text="@string/habit_name"
        android:textSize="20sp"
        android:textStyle="bold" />

    <EditText
        android:id="@+id/habit_name"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:layout_weight="1"
        android:inputType="textCapWords" />

    <TextView
        android:id="@+id/text_view_start_date"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="16dp"
        android:layout_weight="1"
        android:text="@string/start_date"
        android:textSize="20sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/date"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="8dp"
        android:layout_weight="1"
        android:textSize="20sp"
        tools:text="@string/start_date" />

    <TextView
        android:id="@+id/text_view_number_of_times"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="16dp"
        android:layout_weight="1"
        android:text="@string/times"
        android:textSize="20sp"
        android:textStyle="bold" />

    <EditText
        android:id="@+id/number_of_times"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:layout_weight="1"
        android:inputType="number" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginBottom="16dp"
        android:layout_marginTop="40dp"
        android:layout_weight="1"
        android:gravity="center">

        <Button
            android:id="@+id/save_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/save" />

    </LinearLayout>

</LinearLayout>

LinearLayout
中的
android:weightSum:“8”
为例。这会解决你的问题

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum:"8"
android:orientation="vertical">

.......

</LinearLayout>

.......

发布您的代码片段请显示xml。同时添加java文件。@IntelliJAmiya在描述中添加了xml发布您的代码文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum:"8"
android:orientation="vertical">

.......

</LinearLayout>