为什么打不开
import java.util.Calendar;
import android.app.Activity;
import android.os.Bundle;
import android.widget.DatePicker;
import android.widget.TimePicker;
public class MainActivity extends Activity {
private DatePicker datepicker;
private TimePicker timepicker;
private int year;
private int month;
private int day;
private int hour;
private int minute;
//获取当前时间的类
private Calendar cal;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
//获取日历的一个对象
cal = Calendar.getInstance();
year = cal.get(Calendar.YEAR);
//月份从0月开始
month = cal.get(Calendar.MONTH) +1;
day = cal.get(Calendar.DAY_OF_MONTH);
hour = cal.get(Calendar.HOUR_OF_DAY);
minute = cal.get(Calendar.MINUTE);
setTitle(year+month+day+hour+minute);
}
}
是因为哪里不一样吗,在手机上运行,点开就闪一下就退了