EditText input type textCapSentences not working on Lollipop

拈花ヽ惹草 提交于 2019-12-10 01:08:29

问题


I have implemeted android:inputType="textAutoComplete|textCapSentences" in my xml code. When I run it on kitkat, textCapSentence works fine but when build is run on Lollipop device it does not work. Anybody knows how to solve it.


回答1:


Hi this is because in lollipop if you have disabled Auto - Capitalization in keyboard settings then you can't enable it programmatically.

here are the steps:-

  • Tap icon of ‘Settings’ on the Home screen of your Android Lollipop Device
  • At the ‘Settings’ screen, scroll down to the PERSONAL section and tap the ‘Language & input’ section.
  • At the ‘Language & input’ section, select your keyboard(which is marked as current keyboard).
  • Now tap the ‘Preferences’.
  • Tap to check the ‘Auto – Capitalization’ to enable it.
  • That’s all!



回答2:


Set this way,

EditText input = (EditText).findViewById(R.id.ID);
input.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);



回答3:


Set input type in XML as well as in JAVA file like this,

In XML,

android:inputType="textCapSentences"

and in JAVA file,

edittext.setRawInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);

This worked for me and make sure your keyboard's Auto-Capitalization setting is Enabled.




回答4:


Add these two attributes. It works.

 android:capitalize="sentences"
 android:inputType="textCapSentences"



回答5:


On which devices and OS specific versions are you trying. Sometime the manufactures are overriding the "InputMethod" on the OS level and it's just not working.

you can also make a test by taking the sources of the EditText from google code and compile it as your EditTextCustom and see if it's working.



来源:https://stackoverflow.com/questions/31697954/edittext-input-type-textcapsentences-not-working-on-lollipop

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