按照视频去操作,为什么APP根本进不去了?更别说刷新了
按照视频去操作,APP进不去,更别说刷新了
按照视频去操作,APP进不去,更别说刷新了
2016-11-12
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//获取日历的一个对象
cal = Calendar.getInstance();
//获取年月日时分秒的信息
year = cal.get(Calendar.YEAR);
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);
date_Picker = (DatePicker)findViewById(R.id.date);
time_Picker = (TimePicker)findViewById(R.id.time);
tv_date = (TextView) findViewById(R.id.tv_date);
tv_time = (TextView) findViewById(R.id.tv_time);
tv_date.setText("现在日期:"+year+"-"+(month+1)+"-"+day);
tv_time.setText("现在时间:"+hour+":"+minute);
//初始化日期
date_Picker.init(year, cal.get(Calendar.MONTH), day, new OnDateChangedListener() {
//监听日期的改变
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
//Toast.makeText(MainActivity.this, "现在时间:"+year+"-"+(monthOfYear+1)+"-"+dayOfMonth, 0).show();
tv_date.setText("现在日期:"+year+"-"+(monthOfYear+1)+"-"+dayOfMonth);
setTitle(year+"/"+(monthOfYear+1)+"/"+dayOfMonth);
}
});
//设置时间为24小时制
time_Picker.setIs24HourView(true);
time_Picker.setOnTimeChangedListener(new OnTimeChangedListener() {
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
// TODO Auto-generated method stub
tv_time.setText("现在时间:"+hourOfDay+":"+minute);
setTitle(hourOfDay+":"+minute);
}
});
new TimePickerDialog(this, new OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// TODO Auto-generated method stub
setTitle(hourOfDay+":"+minute);
}
},hour , minute, true).show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
举报