0

Androidフォンのネイティブダイヤルパッドとしてダイヤルパッドを使用しています。ソフト キーボードの代わりに、ボタン (1,2,.....*,#) を指定しました。そのため、カーソルの可視性とソフト キーボードの非表示が必要です。

私のアプリでは、プレス番号の入力とボタンを表示するための編集テキストを使用して、独自のダイヤル パッドを作成しました。次のオプションを使用して、編集テキストのソフトキーボードを非表示にしました

dialText.setInputType(InputType.TYPE_NULL);

私は2.3.xでコードを実行しており、その下のバージョンでは、編集テキストにカーソルが表示されたダイアル編集テキストでファイルが動作します。しかし、SDK バージョン 4.0 で上記のコードを実行すると、カーソルが表示されません。私の問題は、すべての Android バージョンのデバイスの edittext にカーソルを表示する必要があることです。どうやってするか?私を助けてください。

私が使用しているソフトキーボードを非表示にするには:

dialText.setInputType(InputType.TYPE_NULL);  // hide soft key board 

私の編集テキストxml:

 <EditText
    android:id="@+id/dialText"
    android:layout_width="match_parent"
    android:layout_marginTop="15dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:gravity="center"
    android:singleLine="true"
    android:layout_height="wrap_content"
    android:ems="10" >
</EditText>
4

2 に答える 2

0

onCreate() メソッドでこれを使用して、キーボードを非表示にしてみてください。

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

このコードを試してください。

yourEditTextHere.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId,
                KeyEvent event) {

                InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

                // NOTE: In the author's example, he uses an identifier
                // called searchBar. If setting this code on your EditText
                // then use v.getWindowToken() as a reference to your 
                // EditText is passed into this callback as a TextView

                in.hideSoftInputFromWindow(yourEditTextHere
                        .getApplicationWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);
               // Must return true here to consume event
               return true;

        }
    });
于 2012-08-18T07:07:23.390 に答える
0
android:cursorVisible="true"

私はそれがあなたが探しているものだと思います!

于 2012-08-18T06:38:44.200 に答える