title: Language Change Button
body: <p>I put the code in the setting fragment but after i select language it doesn't change language although I have that language string folder. I believe i need to refresh activity but this is fragment and i don't know how to.</p>
  <pre><code>public class Settings extends Fragment {
      Locale myLocale;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
          View v = inflater.inflate(R.layout.fragment_settings, container, false);
  
          String [] values =
                  {&quot;Please Select Language&quot;,&quot;Myanmar&quot;,&quot;English&quot;,};
          Spinner spinner = (Spinner) v.findViewById(R.id.spinner1);
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this.getActivity(), android.R.layout.simple_spinner_item, values);
          adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
          spinner.setAdapter(adapter);
          spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener () {
  
              public void onItemSelected(AdapterView&lt;?&gt; parent, View view,
                                         int pos, long id) {
  
                  if (pos == 1) {
  
                      Toast.makeText(parent.getContext(),
                              &quot;You have selected Myanmar&quot;, Toast.LENGTH_SHORT)
                              .show();
                      setLocale(&quot;my&quot;);
                  } else if (pos == 2) {
  
                      Toast.makeText(parent.getContext(),
                              &quot;You have selected English&quot;, Toast.LENGTH_SHORT)
                              .show();
                      setLocale(&quot;en&quot;);
                  }
  
              }
  
              public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
                  // TODO Auto-generated method stub
              }
  
          });
  
          return v;
  
      }
  
      public void setLocale(String lang) {
  
          myLocale = new Locale (lang);
          Resources res = getResources();
          DisplayMetrics dm = res.getDisplayMetrics();
          Configuration conf = res.getConfiguration();
          conf.locale = myLocale;
          res.updateConfiguration(conf, dm);
          Intent intent = new Intent(getActivity(), Settings.class);
          startActivity(intent);
      }
  }
  </code></pre>