refresh to a viewpager

0

Hello that such a good day to all I want to know in what way I can do a refresh to a viewpager. my problem arises from the fact that in my pager I have 2 calendars one with which I select a range of dates and in the other I only select a specific date. what I intend is to have a button that cleans the selection of dates as such. my pager works in the following way:

public class PagerDate extends FragmentStatePagerAdapter {
int tabCount;

TabDay tabDay;
TabMonth tabMonth;

@Override
public CharSequence getPageTitle(int position) {
    switch (position){
        case 0:
            return "Por noche";
        case 1:
            return "Por mes";
        default:
            return "";
    }
}

public PagerDate(FragmentManager fm, int tabCount) {
    super(fm);

    this.tabCount = tabCount;
    this.tabDay = TabDay.new_instancia();
    this.tabMonth = TabMonth.new_instancia();
}

@Override
public Fragment getItem(int position) {
    switch (position){
        case 0:
            return tabDay;
        case 1:
            return tabMonth;
        default:
            return null;
    }
}

@Override
public int getCount() {
    return tabCount;
}

public void SetDate(ItemDayWeek item, int position){
    tabMonth.OnCLickListDay(item, position);
}

public void SetDay(ItemDay item, int position){
    tabMonth.OnCLickMes(item, position);
}

public void SetDate(){
    tabMonth.SetDate();

}

public void Today(){
    tabMonth.Today();
}

public void Cancel(){
    tabMonth.Cancel();
}

public void Select(){
    tabMonth.Select();
}

public void SetDay(){
    tabMonth.SetDay();
}

public CalendarPickerView getCalendarPickerViewNoche(){
    return tabDay.getCalendarView();
}

public void CleanCalendar(){
    tabDay.CleanCalendar();
}



public CalendarPickerView getCalendarPickerViewMes(){
    return tabMonth.getCalendarView();
}

public ItemDay getDayselected(){
    return tabMonth.getDayselected();
}}

my tab's work:

 calendarView = rootView.findViewById(R.id.calendar_view);
    Calendar nextYear = Calendar.getInstance();
    nextYear.add(Calendar.YEAR, 1);
    Date today = new Date();
    calendarView.init(today, nextYear.getTime())
            .inMode(RANGE);

and the XML is as follows:

<com.squareup.timessquare.CalendarPickerView
    android:id="@+id/calendar_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/dos"
    android:layout_marginTop="@dimen/margin2"
    android:layout_marginLeft="@dimen/margin2"
    android:layout_marginRight="@dimen/margin2"/>

<LinearLayout
    android:id="@+id/dos"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="@dimen/margin14"
    android:layout_marginTop="@dimen/margin4">

    <RelativeLayout
        android:layout_weight="1"
        android:paddingLeft="@dimen/margin4"
        android:paddingRight="@dimen/margin2"
        android:layout_width="0dp"
        android:layout_height="wrap_content">

        <Button
            android:text="BORRAR FECHA"
            android:onClick="CleanCalendar"
            android:textColor="@color/md_white_1000"
            android:textSize="@dimen/text_size_medium"
            android:background="@drawable/background_grey_esq"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </RelativeLayout>

    <RelativeLayout
        android:layout_weight="1"
        android:paddingRight="@dimen/margin4"
        android:paddingLeft="@dimen/margin2"
        android:layout_width="0dp"
        android:layout_height="wrap_content">

        <Button
            android:id="@+id/button_fijar_fecha"
            android:text="FIJAR FECHA"
            android:textColor="@color/md_white_1000"
            android:textSize="@dimen/text_size_medium"
            android:background="@drawable/background_green_esq"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:onClick="onClickdates"/>
    </RelativeLayout>
</LinearLayout>

As you can see I have put a listened Onclick in the XML called "CleanCalendar" which at the moment only prints a message in the log. and which I also control from my activity. I hope to have made me understand and if someone comes up with a better solution to the refresh that I intend the proposal will also be well received.

    
asked by Valdemar Allan Poe 06.07.2018 в 16:25
source

0 answers