我有代码,日期用于通过按钮自动存储 现在,按下此按钮后,我还需要显示日期。如何做到这一点
public class datebutton extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
final Button button = (Button) findViewById(R.id.date);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Date today = new Date();
//Convert to calendar Object
Calendar calendar = Calendar.getInstance();
calendar.setTime(today);
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
}
});
}
}
我的活动xml代码是
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="DAte"
android:text="DATE"
android:textSize="27sp"
android:id="@+id/date" />
提前帮助我