简体   繁体   English

editText.getText()。toString()检索所有大写字符串

[英]editText.getText().toString() retrieves the String all uppercase

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. 我只希望editText.getText().toString()将普通的String插入EditText,但是无论如何,我都将其全部大写。

Relevant XML: 相关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: 相关的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. 作为final String变量的firstName始终为大写。 Now whys that? 现在为什么呢? and how do i solve it? 以及我该如何解决?

Is this at all related to your problem? 这完全与您的问题有关吗? Why is my Button text forced to ALL CAPS on Lollipop? 为什么我的Button文本被迫在Lollipop上全部大写?

I would try adding android:textAllCaps="false" to the button. 我会尝试将android:textAllCaps="false"到按钮。

Try to check the string by log or by System.out.println() . 尝试通过logSystem.out.println()检查字符串。 getText() don`t make the text uppercase. getText()不要使文本大写。 see this thread Cannot lower case button text in android studio 在Android Studio中看到此线程无法小写按钮文本

Hope it helps you. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的所有 EditText.getText().toString() 都返回一个空字符串? - Why are all my EditText.getText().toString() returning an empty String? EditText.getText()。toString()崩溃 - EditText.getText().toString() crashes 片段中的EditText.getText()。toString()返回空 - EditText.getText().toString() in a fragment returns empty Android:EditText.getText()。toString()无法正常工作 - Android: EditText.getText().toString() not working Java / Android Edittext.gettext()。toString不起作用 - Java/Android Edittext.gettext().toString not working editText.getText()。toString返回空 - editText.getText().toString returns empty 单击按钮时EditText.getText()。toString()崩溃 - EditText.getText().toString() crashes on button click 使用ViewModel设置数据后,在onCreate()处EditText.getText()。toString()为空 - EditText.getText().toString() is Empty at onCreate() after setting data with ViewModel editText.getText().toString() 无法输入数据 - editText.getText().toString() can't enter data 错误:无法从EditText.getText()。toString();中的静态内容中引用非静态方法gettext(); - Error: Non-Static method gettext() cannot be refrenced from a static content in EditText.getText().toString();
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM