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");
}
精彩评论