In the Google Stock Android Calendar there exists several Views (Month, Week, Agenda, Week), the source code downloaded from Google Android Sources Repositories have the same application, by exploring the code the package named com.android.calendar
has the main views responsible for rendering these activities :
with hard working around the code I used two packages com.android.calendar.month
and com.android.calendar
but couldn't achieve my goal, this is a sample of what I used:
and the following code for the main:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
and here is my xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/month"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:paddingTop="1dip"
android:background="@null">
<TextView android:id="@+id/month_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dip"
android:visibility="gone"
style="@style/MonthView_MiniMonthLabel" />
<include android:id="@+id/day_names" layout="@layout/full_month_header" />
<View
android:background="@color/calendar_grid_line_inner_vertical_color"
android:layout_height="1px"
android:layout_width="match_parent" />
<com.android.calendar.month.MonthListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="false" />
</LinearLayout>
Till here the code works fine, but the with a blank white screen and an actionbar, if my question was not clear please try to edit it.
What should be done to include Calendar Views (Month, Week, Day) in a custom application ?
You should take a look at CalendarView it is the standard way of integrating calendars in Android.
Also, if you need to select Dates & Time in your UI, there are DatePicker and TimePicker.
Remember that the default calendar app in android is open-source! Feel free to dig through the code here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With