嗨,我的string.xml文件中有一个带有字符串的链接列表,并且我有一个string-en.xml文件,我在我的主要活动中运行以下代码,以便将应用程序的语言从希腊语设置为英语但是链表中现有的字符串不会被翻译
//code running in my Main Activity
Locale locale = new Locale("en");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
onCreate(null);
public class Question extends Activity {
AdView mAdView;
Random r = new Random();
String name;
int rand1 ;
int rand2;
String gender;
ConstraintLayout cl;
String q;
TextView question;
Player g = (Player) getApplication();
///lvl 3
public LinkedList<Quest> MaleList = new LinkedList<Quest>();
public LinkedList<Quest> FemaleList = new LinkedList<Quest>();
//lvl2
public LinkedList<Quest> Male2List = new LinkedList<Quest>();
public LinkedList<Quest> Female2List = new LinkedList<Quest>();
//lvl1
public LinkedList<Quest> Male1List = new LinkedList<Quest>();
public LinkedList<Quest> Female1List = new LinkedList<Quest>();
public LinkedList<Quest> TMaleList = new LinkedList<Quest>();
public LinkedList<Quest> TFemaleList = new LinkedList<Quest>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.activity_question);
AddTruthQuestions();
AddDareQuestions();
}
private void AddTruthQuestions()
{
TMaleList.add(new Quest(getString(R.string.TMale4)));
}
private void AddDareQuestions()
{
FemaleList.add(new Quest(getString(R.string.Female1)));
FemaleList.add(new Quest(getString(R.string.Female2)));
}
}