title: How to fix setError message appear in different languages?
body: <p>I created a login page and this page support 2 different languages <strong>(English and French)</strong>.</p>
  
  <p>The page works fine when i translate from language to language.</p>
  
  <p>But the problem is when i switch to <strong>french language</strong> the <strong>setError message</strong> does not appear anymore for the fields validations.</p>
  
  <p>This code will load the page based on lang selection:</p>
  
  <pre><code> public boolean onOptionsItemSelected(MenuItem item) {
  
              switch (item.getItemId()) {
  
                  case R.id.eng:
                  String languageToLoad = "en";
                  Locale locale = new Locale(languageToLoad);
                  Locale.setDefault(locale);
                  Configuration config = new Configuration();
                  config.locale = locale;
                  getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
                  this.setContentView(R.layout.activity_main);
                  break;
  
                  case R.id.fr:
                  languageToLoad = "fr";
                  locale = new Locale(languageToLoad);
                  Locale.setDefault(locale);
                  config = new Configuration();
                  config.locale = locale;
                  getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
                  this.setContentView(R.layout.activity_main);
                  break;
  
                  default:
                  break;
          }
          return super.onOptionsItemSelected(item);
      }
  </code></pre>
  
  <p>And here is the validation for Username field and the <strong>setError message</strong>:</p>
  
  <pre><code>private boolean validateUsername(){
  
          String username = usernameEditText.getText().toString().trim();
  
          if(username.isEmpty()){
  
              usernameEditText.setError("Field can't be empty");
              return false;
  
          } else if(username.length() &gt; 15){
  
              usernameEditText.setError("Username too long");
              return false;
  
          } else {
              usernameEditText.setError(null);
              return true;
          }
      }
  </code></pre>
  
  <p>The XML code:</p>
  
  <pre><code>      &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity"&gt;
  
      &lt;EditText
          android:id="@+id/usernameEditText"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginTop="300dp"
          android:ems="10"
          android:hint="@string/YourUsername"
          android:inputType="textPersonName"
          android:maxLength="15"
          app:errorEnabled="true" /&gt;
  
      &lt;Button
          android:id="@+id/signupButton"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/test3"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="20dp"
          android:onClick="signupLogin"
          android:hint="@string/login" /&gt;
  &lt;/android.widget.RelativeLayout&gt;
  </code></pre>
  
  <p>The popup msg between the 2 languages:</p>
  
  <p><a href="https://i.stack.imgur.com/UOAo3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UOAo3.png" alt="English Language Msg"></a> <a href="https://i.stack.imgur.com/H2J6O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H2J6O.png" alt="French Language without popup"></a></p>
  
  <p>Here i set the error message in <strong>English</strong> but what are the ways to add to setError message to support different languages ?</p>
  
  <p>Thank you!</p>