forked from alamkanak/Android-Week-View
-
Notifications
You must be signed in to change notification settings - Fork 64
Usage
Jesse Hoobergs edited this page Feb 9, 2018
·
2 revisions
- Import the library into your project.
-
Grab via maven
<dependency> <groupId>com.github.quivr</groupId> <artifactId>android-week-view</artifactId> <version>2.2.2</version> <type>aar</type> </dependency>
-
Grab via gradle
compile 'com.github.quivr:android-week-view:2.2.2'
-
The latest version can be found by checking https://search.maven.org/#search%7Cga%7C1%7Cquivr
-
Add WeekView in your xml layout. (see Customization for all possible attributes.)
<com.alamkanak.weekview.WeekView android:id="@+id/weekView" android:layout_width="match_parent" android:layout_height="match_parent" app:eventTextColor="@android:color/white" app:textSize="12sp" app:hourHeight="60dp" app:headerColumnPadding="8dp" app:headerColumnTextColor="#8f000000" app:headerRowPadding="12dp" app:columnGap="8dp" app:noOfVisibleDays="3" app:headerRowBackgroundColor="#ffefefef" app:dayBackgroundColor="#05000000" app:todayBackgroundColor="#1848adff" app:headerColumnBackground="#ffffffff"/>
-
Write the following code in your java file.
// Get a reference for the week view in the layout. mWeekView = (WeekView) findViewById(R.id.weekView); // Set an action when any event is clicked. mWeekView.setOnEventClickListener(mEventClickListener); // The week view has infinite scrolling horizontally. We have to provide the events of a // month every time the month changes on the week view. mWeekView.setMonthChangeListener(mMonthChangeListener); // Set long press listener for events. mWeekView.setEventLongPressListener(mEventLongPressListener);
-
Implement the interfaces according to your need. See Interfaces for all possible interfaces.)
-
Provide the events for the
WeekView
inWeekView.MonthChangeListener.onMonthChange()
callback.MonthLoader.MonthChangeListener mMonthChangeListener = new MonthLoader.MonthChangeListener() { @Override public List<WeekViewEvent> onMonthChange(int newYear, int newMonth) { // Populate the week view with some events. List<WeekViewEvent> events = getEvents(newYear, newMonth); return events; } };