OnDateChangedListener()剪辑器报红
datePicker.init(year, month, day, new OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
datePicker.init(year, month, day, new OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
2016-01-21
import java.util.Calendar;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.DatePicker;
import android.widget.TimePicker;
public class MainActivity extends Activity {
private TimePicker timePicker;
private DatePicker datePicker;
private Calendar cal;
private int year;
private int month;
private int hour;
private int day;
private int minute;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//获取日历的一个对象
cal=Calendar.getInstance();
//获取年月日时分秒的信息
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);
datePicker=(DatePicker) findViewById(R.id.datePicker);
timePicker=(TimePicker) findViewById(R.id.timePicker);
//datePicker初始化操作
datePicker.init(year , month, day, new OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
}
});
举报