1

I just want the editText.getText().toString() to get the normal String inserted to the EditText but instead I'm getting it all uppercase no matter what.

Relevant XML:

    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/first_name_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/first_name_text"
        android:textSize="20sp"
        />

    <EditText
        android:id="@+id/first_name_edit_text_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="@string/first_name_hint_text"
        />

    </LinearLayout>

Relevant Java:

sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
sharedPreferencesEditor = sharedpreferences.edit();

    signUpButton.setOnClickListener(new View.OnClickListener()
    {   
        @Override
        public void onClick(View v) 
        {
            final String firstName = sharedpreferences.getString(FIRST_NAME_KEY, "");
            sharedPreferencesEditor.putString(FIRST_NAME_KEY, firstNameEditText.getText().toString());
            sharedPreferencesEditor.apply();

            signUpButton.setText(firstName);
        }
    });

The firstName which is a final String variable is always uppercase. Now whys that? and how do i solve it?

God
  • 1,238
  • 2
  • 18
  • 45
  • 1
    Is it anywhere else as well you are saving `FIRST_NAME_KEY` in the preferences? Also can you include code that initializes `firstNameEditText` and uses? – Shobhit Puri Aug 19 '15 at 14:35
  • Man, `getText()` don`t make the text uppercase. Probably there is something else in the code that is making it upper. – Thiago Moura Aug 19 '15 at 14:57

2 Answers2

2

Is this at all related to your problem? Why is my Button text forced to ALL CAPS on Lollipop?

I would try adding android:textAllCaps="false" to the button.

Community
  • 1
  • 1
1

Try to check the string by log or by System.out.println(). getText() don`t make the text uppercase. see this thread Cannot lower case button text in android studio

Hope it helps you.

Community
  • 1
  • 1
Deepak Goyal
  • 4,747
  • 2
  • 21
  • 46