这是ChooseLanguage
类:
languagelist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getApplicationContext(), "you select "+lag[position]+" language", Toast.LENGTH_LONG).show();
switch (position){
case 0:
mytranslate.TamilLanguage();
list_dialog.hide();
break;
case 1:
mytranslate.EnglishLanguage();
list_dialog.hide();
break;
}
}
});
list_dialog.show();
}
这是Translate
类:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sample);
e1=(EditText)findViewById(R.id.input1);
}
public void TamilLanguage(){
final Typeface tamil_font = Typeface.createFromAsset(getApplication().getAssets(), "Tamil.ttf");
e1.setTypeface(tamil_font);
Toast.makeText(getApplicationContext(), "you select Tamil Language", Toast.LENGTH_LONG).show();
}
public void EnglishLanguage(){
final Typeface english_font= Typeface.createFromAsset(getApplication().getAssets(), "English.ttf");
e1.setTypeface(english_font);
Toast.makeText(getApplicationContext(),"you select English Language",Toast.LENGTH_LONG).show();
}
我在ChooseLanguage
课程中选择了字体,但在MyTranslate
课程中它不起作用,这是我的代码,请参考。
如果我点击一个按钮,它将显示一个列表1.English 2.Tamil。如果我选择一种语言,它将改变edittext字体。
请帮我解决这个问题。
答案 0 :(得分:0)
您需要刷新当前的活动。
Intent intent = getIntent();
finish();
startActivity(intent);