[英]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()
. 尝试通过
log
或System.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.