2015-08-19 28 views
1

我只是想要editText.getText().toString()獲取插入到EditText的正常字符串,但是我無論如何都將其全部大寫。editText.getText()。toString()檢索字符串全部大寫

相關的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> 

相關的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); 
     } 
    }); 

firstName這是一個final字符串變量始終是大寫的。 現在是誰?我如何解決它?

+1

其他任何地方以及您在首選項中保存「FIRST_NAME_KEY」?你也可以包含初始化'firstNameEditText'並使用它的代碼嗎? –

+0

man,'getText()'不能使文本大寫。可能在代碼中還有其他的東西讓它變得更高。 –

回答

相關問題