3

アクティビティの編集テキストを含むグリッドビューがあり、その下にカスタムキーパッドがあります。以下のコードでわかるように、数字を入力するためのボタンを追加しました。しかし、問題は、グリッドビューで編集テキストをクリックするたびにソフトキーパッドがポップアップすることです。

マニフェストファイルを入れてみandroid:windowSoftInputMode="stateHidden"ましたが、私の場合はソフトキーパッドも隠していません。投稿を1つも残さずに、stackoverflowを含む多くのソースを参照しました。main.xmlファイルに問題があると思います。これをgridviewの子に隠すことはできません(これはばかげているように見えますが、これは私が多くのことを試した後に得た最後の疑問です)。誰かが私がどこで間違っているのか提案できますか?次のコードをあなたの答えでテストし、それが機能するかどうか私に提案していただければ幸いです。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

        <FrameLayout
                android:id="@+id/fLayout1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="2"
                android:background="@drawable/background3">
        <GridView xmlns:android="http://schemas.android.com/apk/res/android" 
                android:id="@+id/gridview"
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                android:columnWidth="18dp"
                android:numColumns="6"
                android:verticalSpacing="0dp"
                android:horizontalSpacing="1dp"
                android:stretchMode="columnWidth"
                android:gravity="center"
                android:listSelector="@null"/>
        </FrameLayout>

        <FrameLayout
                android:id="@+id/fLayout2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="4"
                android:background="@drawable/background2">

        <TableLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/keypad"
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:stretchColumns="*">

        <TableRow>
        <Button android:id="@+id/keypad_1"
        android:text="1"
        android:background="@drawable/custombutton">
        </Button>
        <Button android:id="@+id/keypad_2"
        android:text="2"
        android:background="@drawable/custombutton">
        </Button>
        <Button android:id="@+id/keypad_3"
        android:text="3"
        android:background="@drawable/custombutton">
        </Button>

        <Button android:id="@+id/keypad_4"   
        android:text="4"
        android:background="@drawable/custombutton">
        </Button>

        <Button android:id="@+id/keypad_5"
        android:text="5"
        android:background="@drawable/custombutton">
        </Button>

        </TableRow>
        <TableRow>



        <Button android:id="@+id/keypad_6"
        android:text="6"
        android:background="@drawable/custombutton">
        </Button>

        <Button android:id="@+id/keypad_7"
        android:text="7"
        android:background="@drawable/custombutton">
        </Button>
        <Button android:id="@+id/keypad_8"
        android:text="8"
        android:background="@drawable/custombutton">
        </Button>
        <Button android:id="@+id/keypad_9"
        android:text="9"
        android:background="@drawable/custombutton"> 
        </Button>

        <Button android:id="@+id/keypad_10"
        android:text="C"
        android:background="@drawable/custombutton">
        </Button>

        </TableRow>
        <TableRow>
        <Button android:id="@+id/submit"
        android:text="submit"
        android:layout_span="5"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/custombutton">

        </Button>
        </TableRow>
        </TableLayout>

        </FrameLayout>
</LinearLayout>
4

1 に答える 1

1

メソッドにこの行を追加しようとしましたonCreate()か?

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

また

stateHiddenマニフェストで以前に行ったことを試してください。stateAlwaysHidden

また

onTouchにリスナーを配置しようとしましたEditTextか? 私が間違っていなければ、タッチイベントを「消費」し、キーボードは表示されません。何かのようなもの:

editText_input_field.setOnTouchListener(otl);

private OnTouchListener otl = new OnTouchListener() {
    public boolean onTouch (View v, MotionEvent event) {
            return true; // the listener has consumed the event
    }
 };

ここから撮影

何かうまくいくかどうか教えてください:)。そうでない場合は、他の解決策を考えます...

于 2012-09-17T09:28:26.823 に答える