开发者

Setting the time on a button in a different Activity in Android

In my application I have two activities. In the first acti开发者_开发技巧vity I have a button, and in the second activity I have another button. My problem is, when the user presses the first button I want to set the time display on the second button in the second activity. Can any one help me with a solution?


Pass the value of one button to the second activity:

String text = button.getText();
Intent intent = new Intent(this, SecondActivity.class);
intent.putExtra("time", text);

in second activity:

Intent intent = getIntent();
if (intent.getExtras() != null) {
  String time = intent.getExtras().getString("time");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜