0

通常の整数または 10 進数を入力できるように、次のコードでは "Done" キーを備えた数字キーパッドのみを表示したいと考えています。しかし、代わりに、「次へ」キーを備えたテンキーを取得しています。この「次へ」キーを押すと、望まないアルファベットのキーパッドに移動します。値が挿入され、次へまたは完了キーが押された後、アクティビティ画面に直接移動したい。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" 
android:background="@drawable/black">

<RelativeLayout
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:orientation="vertical"
    android:paddingLeft="30dp"
    android:paddingRight="30dp"
    android:paddingTop="100dp">

    <LinearLayout
        android:id="@+id/layout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <EditText
            android:id="@+id/editText1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:hint="@string/select_from"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:inputType="number|numberSigned|numberDecimal" 
            android:layout_weight="1">  
        </EditText>

        <Spinner
            android:id="@+id/spinner1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:entries="@array/angle_List"
            android:gravity="center"
            android:layout_weight="1" >
        </Spinner>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/layout2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/layout1"
        android:layout_marginTop="50dp">
        <TextView
            android:id="@+id/textView1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:hint="@string/select_to"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/white"
            android:textIsSelectable="true"
            android:layout_weight="1" >
        </TextView>

        <Spinner
            android:id="@+id/spinner2"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:entries="@array/angle_List"
            android:gravity="center"
            android:layout_weight="1">
        </Spinner>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/layout3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/layout2"
        android:layout_marginTop="60dp">
        <Button
            android:text="@string/convert" 
            android:id="@+id/button1" 
            android:layout_height="fill_parent" 
            android:layout_width="fill_parent" 
            android:layout_weight="1"
            android:onClick="Convert">
        </Button>

        <Button
            android:id="@+id/button2"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:onClick="clearVal"
            android:text="@string/clear">
        </Button>   
    </LinearLayout>

</RelativeLayout>
</ScrollView>

前もって感謝します

アップデート-

を使用して問題を解決しました

android:imeOptions="actionDone"

私のタグで

4

1 に答える 1

0

これを試して:

EditText edit = (EditText)findViewById(R.id.editText1);
edit.setOnFocusChangeListener(new OnFocusChangeListener() {

    @Override
    public void onFocusChange(View v, boolean hasFocus) {
        ((EditText)v).setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        }
    });
于 2013-04-13T15:36:39.550 に答える