I want to use CalenderView
on my activity, I also try to clean my project but this problem not solved.
This is my code:
Cal_view.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CalendarView
android:layout_width="match_parent"
android:layout_height="264dp" />
</LinearLayout>
Main.xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.example.malik.auealert.HistoryActivity">
<include
android:id="@+id/calendarView"
layout="@layout/cal_view" />
</RelativeLayout>
ActivityClass:
public CalendarView c;
// public TextView t;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);
// LinearLayout parent = (LinearLayout) View v;
/* ***ERROR Appear on here***: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.CalendarView */
c = (CalendarView) findViewById(R.id.calendarView);
//t = (TextView) findViewById(R.id.message);
c.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
}
});
I searched Google for a solution, but couldn't find one.