LoginSignup
3
4

More than 5 years have passed since last update.

デフォルトを数字キーボードにしつつ文字も入力したい

Last updated at Posted at 2015-11-11

[1] 数字キーボードを表示させる

AndroidのIMEで表示するキーボードは、TextView#setInputTypeで変更することができます。

<EditText
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:inputType="number"
        />

もしくは、javaで

editText.setInputType(InputType.TYPE_CLASS_NUMBER);

問題点 : inputTypeをnumberにしてしまうと、数値以外の入力が出来ない。

[2] 数字キーボードにしつつ日本語入力も可能にする

TextView#rawinputを利用をすると数値以外も入力できるようになります

editText.setRawInputType(Configuration.KEYBOARD_QWERTY)

問題点 : 日本語の入力はできるようになりますが、残念ながら変換機能が有効になりません。

デフォルト表示が数字キーボードで、日本語入力も可能にしつつ、変換も可能な状態にしたいけどどうすればいいんだ..

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4