I have a screen where I would like the user to click and open the system's native calendar. But I would like the CalendarView
to be opened even if I clicked on the RelativeLayout
that covers it. I already gave an ID for RelativeLayout
, but how do I open CalendarView
.
Javacodetogetthedate:
@OverridepublicvoidonSelectedDayChange(CalendarViewcalendarView,intyears,intmonth,intdayOfMonth){Toast.makeText(getApplicationContext(),dayOfMonth+"/" + month + "/" + years, Toast.LENGTH_LONG).show();
}
});
XML Code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/card_view_1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_margin="5dp">
<RelativeLayout
android:id="@+id/calendar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView37"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginLeft="24dp"
android:layout_marginStart="24dp"
android:text="@string/datapgto"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/editText4"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:ems="10"
android:inputType="date" />
</RelativeLayout>
</android.support.v7.widget.CardView>