Android multiline number edittext

三世轮回 提交于 2019-12-10 22:30:33

问题


I want to create an EditText in Android which has several lines and number input. It is for the input of a matrix. I already have a solution to set android:inputType="textMultiLine" and then setRawInputType(Configuration.KEYBOARD_12KEY). However, this does not work when editing the edittext in horizontal orientation and it also does not show the slash (/) which I need to input fractions. If I set the input type tosetRawInputType(InputType.TYPE_CLASS_NUMBER), it also does not work in horizontal orientation and always after I enter a space, it switches to the normal input keyboard. Do you know any solution which would help me?


回答1:


In this way could be created multiline EditText which allow only numbers and has digit keyboard

   <EditText

                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:digits="0,1,2,3,4,5,6,7,8,9,/"
                android:inputType="textMultiLine|phone" />



回答2:


try it , i use this for edittext with multiline and inputtye phone

   <EditText
            android:id="@+id/txt_mobiles"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:digits="0,1,2,3,4,5,6,7,8,9,\n"
            android:inputType="phone"/>

replace number instead of phone




回答3:


Try this

 <EditText 
      android:inputType="textMultiLine" 
      android:digits="0,1,2,3,4,5,6,7,8,9,/" 
      android:hint="Only letters, / allowed"/>



回答4:


It will be:

   <EditText
        android:inputType="textMultiLine|number"
        android:singleLine="false" 
        android:digits= "0123456789" />

Not:

   <EditText
        android:inputType="textMultiLine|number"
        android:singleLine="false"
        android:digits= "0,1,2,3,4,5,6,7,8,9" />

If you put comma into digits, then you can take , as input. Like: 12154,454 . Thanks




回答5:


Try it, i use this for Edittext with multiline number

android:singleLine="false"
android:digits="0123456789"


来源:https://stackoverflow.com/questions/17153237/android-multiline-number-edittext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!