Droidster
Droidster

Reputation: 127

Android code - any way to override text input box to lowercase?

I have a specific situation, I'm using EditTextPreference in preferences to allow user to input word/name for a preference. When app opens text input box I need it to be in lowercase, it seems default is in uppercase for first letter.

<EditTextPreference
        android:title="Your Name"
        android:key="yname"
        android:capitalize="none" <-- DOES NOT WORK..
        android:summary="name:"
        android:defaultValue="george"
         >
    </EditTextPreference>

When this app uses preferences code and user selects item it opens text input box with caps lock on first letter... urgh! lol !

Can I simply use an @Override on the default use of uppercase for first letter in the input text box?

Upvotes: 3

Views: 1371

Answers (2)

Tamir Scherzer
Tamir Scherzer

Reputation: 1035

seems android:inputType="text" should clear all capitalization flags:

http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType

Upvotes: 2

Luis
Luis

Reputation: 12058

You can use the folowing in your preferences class.

  public class TaskPreferences extends PreferenceActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      addPreferencesFromResource(R.xml.task_preferences);

      EditTextPreference xx = (EditTextPreference) findPreference(getString(R.string.your_pref_key));;
      xx.getEditText().setKeyListener(TextKeyListener.getInstance(false, TextKeyListener.Capitalize.NONE));
    }
}

Upvotes: 0

Related Questions