EditText input type textCapSentences not working on Lollipop

你离开我真会死。 提交于 2019-12-05 01:19:55

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!

Set this way,

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

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.

Add these two attributes. It works.

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

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.

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