使用setText更改文本后,如何更新屏幕..
代码:
TextView settings_text = (TextView) findViewById(R.id.tv_settings);
settings_text.setText(Strings.SETTINGS);
TextView terms_text = (TextView) findViewById(R.id.tv_terms);
terms_text.setText(Strings.TERMS);
TextView about_text = (TextView) findViewById(R.id.tv_aboutus);
about_text.setText(Strings.ABOUT);
Intent intent = new Intent(Language.this,MenuScreen.class);
startActivity(intent);
finish();
问题: 在此之后这些值没有反映在屏幕上
建议我......谢谢你
答案 0 :(得分:0)
延迟开始第二项活动:
import android.os.Handler;
new Handler().postDelayed(new Runnable(){
public void run(){
Intent intent = new Intent(Language.this,MenuScreen.class);
startActivity(intent);
}
},5000); // 5000 is represent time to delay execute code under run().
答案 1 :(得分:0)
使用警报对话框
TextView terms_text = (TextView) findViewById(R.id.tv_terms);
terms_text.setText(Strings.TERMS);
TextView about_text =(TextView)findViewById(R.id.tv_aboutus); about_text.setText(Strings.ABOUT);
TextView contactus_text = (TextView) findViewById(R.id.tv_contactus);
contactus_text.setText(Strings.CONTACT_US);
AlertDialog.Builder alertDialog = new AlertDialog.Builder(Language.this);
alertDialog.setTitle("Alert");
alertDialog.setMessage("Language changed successfully");
alertDialog.setCancelable(false);
alertDialog.setPositiveButton("Continue",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Language.this,MenuScreen.class); startActivity(intent);
finish();
}
});
alertDialog.show();
第二种方式:使用POSTDELAYED METHOD
TextView terms_text =(TextView)findViewById(R.id.tv_terms); terms_text.setText(Strings.TERMS);
TextView about_text =(TextView)findViewById(R.id.tv_aboutus); about_text.setText(Strings.ABOUT);
TextView contactus_text = (TextView) findViewById(R.id.tv_contactus);
contactus_text.setText(Strings.CONTACT_US);
new Handler().postDelayed(new Runnable(){
public void run(){
Intent intent = new Intent(Language.this,MenuScreen.class);
startActivity(intent);
}
},100);