Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CalendarListView in Fragment #44

Open
thanhhaiqtvn opened this issue Jun 21, 2016 · 1 comment
Open

CalendarListView in Fragment #44

thanhhaiqtvn opened this issue Jun 21, 2016 · 1 comment

Comments

@thanhhaiqtvn
Copy link

Hello,

how to add this calendar to Fragment.
Can you show me.
thank u.

@ozcanyarimdunya
Copy link

ozcanyarimdunya commented Jul 10, 2016

CALENDAR_FRAGMENT.JAVA

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.andexert.calendarlistview.library.DatePickerController;
import com.andexert.calendarlistview.library.DayPickerView;
import com.andexert.calendarlistview.library.SimpleMonthAdapter;
import com.yourpackagename.R; //***//

import java.util.Calendar;

public class CalendarFragment extends Fragment implements DatePickerController {

    private DayPickerView dayPickerView;

    public CalendarFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment

        View view = inflater.inflate(R.layout.fragment_calendar, container, false);
        dayPickerView = (DayPickerView) view.findViewById(R.id.pickerView);
        dayPickerView.setController(this);

        return view;
    }

    @Override
    public int getMaxYear() {
        Calendar c = Calendar.getInstance();
        int year = c.get(Calendar.YEAR);
        return year + 1;
    }

    @Override
    public void onDayOfMonthSelected(int year, int month, int day) {

    }

    @Override
    public void onDateRangeSelected(SimpleMonthAdapter.SelectedDays<SimpleMonthAdapter.CalendarDay> selectedDays) {

    }
}

FRAGMENT_CALENDAR.XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:calendar="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".CalendarFragment">

    <com.andexert.calendarlistview.library.DayPickerView
        android:id="@+id/pickerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        calendar:colorCurrentDay="#ff0000"
        calendar:colorSelectedDayBackground="#000000"
        calendar:currentDaySelected="true"
        calendar:drawRoundRect="false"/>

</RelativeLayout>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants