Java 输入类型=编号不起作用

Java 输入类型=编号不起作用,java,android,android-fragments,Java,Android,Android Fragments,首先,这是Nexus5默认输入法的问题 问题是,如果我使用v4 fragment tab host和编辑文本输入类型=数字,当我输入数字时,它将切换到字母键盘,并且编辑文本中没有输入任何内容 我确信这是v4 fragment tab host的问题,因为我尝试了tabhost它可以工作,我只使用活动而不是任何tab host,它可以工作。当输入类型=文本,并切换到num pad时,它工作。我也可以捕捉onKeyDown事件 唯一的失败案例是input type=number,编辑文本在v4 fr

首先,这是Nexus5默认输入法的问题

问题是,如果我使用v4 fragment tab host和编辑文本输入类型=数字,当我输入数字时,它将切换到字母键盘,并且编辑文本中没有输入任何内容

我确信这是v4 fragment tab host的问题,因为我尝试了tabhost它可以工作,我只使用活动而不是任何tab host,它可以工作。当输入类型=文本,并切换到num pad时,它工作。我也可以捕捉onKeyDown事件

唯一的失败案例是input type=number,编辑文本在v4 fragment tabhost中

选项卡片段的布局

<RelativeLayout 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" >

        <EditText
        android:id="@+id/edit_ratio"
        android:layout_width="150dp"
        android:layout_height="50dp"
        android:layout_gravity="center"
        android:layout_marginBottom="5dp"
        android:digits="0123456789."
        android:inputType="number"
        android:maxLength="4"
        android:padding="5dp"
        android:textSize="16sp" />

</RelativeLayout>

而且,我只在Nexus5中使用名为简化仓颉键盘的输入法时才发现这种情况。所以我想知道如何修复它。真的非常感谢

输入数字、字母或特殊字符时,inputtype=数字不起作用
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/tabBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:orientation="horizontal"
            android:visibility="gone" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" />
        </LinearLayout>

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="0" />

        <FrameLayout
            android:id="@+id/realtabcontent"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />
    </LinearLayout>

</android.support.v4.app.FragmentTabHost>
public class Main extends ActionBarActivity {

    public static FragmentTabHost tabHost;
    public static LinearLayout tabBar;
    private String[] tags = { "home", "form", "calculator", "phone", "partner", "about_us", "settings" };

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
        tabBar = (LinearLayout) findViewById(R.id.tabBar);
        tabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);

        tabHost.addTab(
                tabHost.newTabSpec(tags[0]).setIndicator(""),
                HomeFragment.class, null);


    }

}