我想在调用onResume()时更改按钮上的文本,(setText正常工作,因为如果我执行Toast它会显示我想要的文本,但按钮具有旧字符串)。
@Override
public void onResume() {
super.onResume();
if(ban == 0) {
reDraw();
fillInfo();
SharedPreferences sharedPreferences = getSharedPreferences("layoutRequestData", Context.MODE_PRIVATE);
getFlagSendBill = sharedPreferences.getBoolean("flagSendBill", false);//comenzar servicio
if(getFlagSendBill == true) {
View view = LayoutInflater.from(this).inflate(R.layout.request,null);
buttonBService = (Button) view.findViewById(R.id.buttonBeginService);
//buttonBService = (Button) findViewById(R.id.buttonBeginService);
buttonBService.setText("Ver Recibo");
Toast.makeText(this,"LALALA" + buttonBService.getText(),Toast.LENGTH_SHORT).show();
}
else{
// buttonBService = (Button) findViewById(R.id.buttonBeginService);
//buttonBService.setText("Comenzar Servicio");
}
}
}
我的buttonBService和我的getFlagSendBill是公开的