0

Possible Duplicate:
Change language programatically in Android

I am creating Application which is a form type application. here user need to enter the details which on submitting gets inserted into database.

We need to give language option within the application. It will be radiobutton option where user on selecting the option layout gets refreshed with the new language.

I have used res/value for different language options.

On setOnCheckedChangeListener i have used configuration to update the locale with different Language but

  setContentView(R.layout.leave); 

is getting called only once after on changing the radiobutton values setContentView(R.layout.leave); is not getting called.

Kindly suggest how solve the above problem.

Community
  • 1
  • 1
amit surana
  • 49
  • 2
  • 10

1 Answers1

1

Check this post. Your answer is there. This post will help you how to handle languagle changes programatically.

Code :

android.content.res.Configuration conf = res.getConfiguration();
conf.locale = new Locale(language_code.toLowerCase());
res.updateConfiguration(conf, dm);

When you call this update configuration and if you are not overriding configuration change, it will call the onCreate and setContentView again.

Community
  • 1
  • 1
Eldhose M Babu
  • 14,382
  • 8
  • 39
  • 44
  • i have used the above solution but it gets refreshed once only. after that radiobutton stops working.. i thinks this is because of oncreate not being called after setviewcontent.... – amit surana Aug 30 '12 at 09:31
  • Check whether you have mentioned the android:configChanges in Manifest file for this Activity. If yes, remove it and try. – Eldhose M Babu Aug 30 '12 at 09:34