更新按钮上面文字,并根据变化判断活动

startLocation = (Button) findViewById(R.id.addfence);


startLocation.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
if (startLocation.getText().toString().equals(getString(R.string.startlocation))) {
LocationResult.setVisibility(View.VISIBLE);
//locationService.start();// 定位SDK
// start之后会默认发起一次定位请求,开发者无须判断isstart并主动调用request
Date date = new Date();
LocationActivity.workid = new SimpleDateFormat("MMddHHmm").format(date);
Intent idintent = new Intent(LocationActivity.this, MyLocationService.class);
idintent.putExtra("workid", LocationActivity.workid);
startService(idintent);
startLocation.setText(getString(R.string.stoplocation));
} else {
//locationService.stop();
stopService(new Intent(LocationActivity.this, MyLocationService.class));
getdialog();
startLocation.setText(getString(R.string.startlocation));
LocationResult.setVisibility(View.INVISIBLE);
}
}
});
原文地址:https://www.cnblogs.com/to-creat/p/5684699.html