1

I am developing the application which consists of AutoCompleteTextView,here is my problem,How I can upper case the letters entering in AutoCompleteTextView.

  1. I Don't want in xml: android:capitalize="characters"
  2. I want to declare in Java code.
Jave
  • 31,598
  • 14
  • 77
  • 90
NikhilReddy
  • 6,904
  • 11
  • 38
  • 58
  • well, capitalize in xml is like setting a keylistener, so you need to programme a keylistener that implements this if you want it in java. there are many similar questions here on SO – keyser Apr 27 '12 at 12:17
  • possible duplicate of [Text-transform:uppercase equivalent in Android?](http://stackoverflow.com/questions/3286343/text-transformuppercase-equivalent-in-android) – st0le Apr 27 '12 at 12:19

2 Answers2

1

You can try like this..In your text watcher in ontextchanged change the text to upper case..and check if the new string in edittext is the old string which you converted to upper case...in order to avoid stackoverflow error..

 String upper = mytextview.getText().toString().toUpperCase()
 mytextview.setText(upper);
5hssba
  • 8,079
  • 2
  • 33
  • 35
0

Try this in your code there are some other flags also which you can check and try.

tv.setInputType(InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
Mehdi
  • 1,494
  • 5
  • 33
  • 53
Bharat Sharma
  • 3,926
  • 2
  • 17
  • 29