Open thanhhaiqtvn opened 8 years ago
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) {
}
}
<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>
Hello,
how to add this calendar to Fragment. Can you show me. thank u.