所以我的日程安排片段代码如下所示。这些代码是从我的later error修复的,但问题是,一旦我点击导航抽屉中的"My Schedule"
,它就会出现无响应错误。请记住,我的Schedule Fragment自己连接到Navigation Drawer。
@TargetApi(Build.VERSION_CODES.N)
public class ScheduleFragment extends Fragment {
CompactCalendarView compactCalendar;
private SimpleDateFormat dateFormatMonth = new SimpleDateFormat("MMM - yyyy", Locale.getDefault());
public ScheduleFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState){
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_schedule, container, false);
final ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setTitle(null);
compactCalendar = (CompactCalendarView) v.findViewById(R.id.compactcalendar_view);
compactCalendar.setUseThreeLetterAbbreviation(true);
Event ev1 = new Event(Color.RED, 1477040400000L, "Teachers' Professional Day");
compactCalendar.addEvent(ev1);
compactCalendar.setListener(new CompactCalendarView.CompactCalendarViewListener() {
@Override
public void onDayClick(Date dateClicked) {
Context c = getContext().getApplicationContext();
if (dateClicked.toString().compareTo("Fri Oct 21 00:00:00 AST 2016") == 0) {
Toast.makeText(c, "Teachers' Professional Day", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(c, "No Events Planned for that day", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onMonthScroll(Date firstDayOfNewMonth) {
actionBar.setTitle(dateFormatMonth.format(firstDayOfNewMonth));
}
});
return v;
}
}
似乎有什么问题?我是否需要实施"extends ActionBarActivity"
或"AppCompatActivity"
?这些中的任何一个都会导致错误@Override method.