嗨,我正在尝试创建将响应 CalendarView 上单击日期的应用程序,将获取所选日期并将其显示在 textview 中,这是我的代码:
public class MyOrganiser1Activity extends Activity {
/** Called when the activity is first created. */
TextView dateView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
CalendarView calendas = (CalendarView)findViewById(R.id.calendarView1);
dateView = (TextView)findViewById(R.id.dateView1);
calendas.setOnDateChangeListener( new CalendarView.OnDateChangeListener() {
private GregorianCalendar calendar;
public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
this.calendar = new GregorianCalendar(year, month, dayOfMonth);
SimpleDateFormat ss = new SimpleDateFormat("yyyy-MM-dd");
String currentdate= ss.format(calendar);
dateView.setText(currentdate);
}
});
}
}
我的问题是:一旦我运行这段代码;我的应用程序崩溃。调试信息:“找不到 DataSetObservable.class 的 android.java”。然而; 我什至不知道上面的代码是否正确。