Android Open Source - BonetCalendarView Custom Month Provider






From Project

Back to project page BonetCalendarView.

License

The source code is released under:

Apache License

If you think the Android project BonetCalendarView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.bonet.example.bonetcalendarviewactivity;
/* w  ww  .ja  v  a  2  s .c  o  m*/
import java.text.DateFormatSymbols;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.GridView;

import com.bonet.views.BtMonth;
import com.bonet.views.GridBtMonthViewProvider;

public class CustomMonthProvider extends GridBtMonthViewProvider {

  public CustomMonthProvider(Context context, BtMonth month) {
    super(context, month);
  }

  @Override
  public View getView() {
    
    /* Let's try something funny here: Inflate a custom for the month view
     * That will show the weekdays names. Shall we?*/
    
    View v = LayoutInflater.from(super.getContext()).inflate(R.layout.custom_month_view, null);
    
    GridView weekdaysContainer = (GridView)v.findViewById(R.id.weekdays_container);
    
    // Sets the names 
    weekdaysContainer.setAdapter(new ArrayAdapter<String>(getContext(), R.layout.weekday_textview, gettWeekdayNames()));
    
    // The actual container
    setGridView((GridView)v.findViewById(R.id.month_container));
    
    // Sets the adapter
    getGridView().setAdapter(getAdapter());
    
    // And sets the listener
    getGridView().setOnItemClickListener(getDefaultItemClickListener());
    
    return v;
  }
  
  /*
   * Returns the list of string containing the weekday names 
   * for the user's current locale.
   * @return
   */
  public List<String> gettWeekdayNames() {
    List<String> defaultWeekNames = new ArrayList<String>();
    
    String [] temp = DateFormatSymbols.getInstance().getShortWeekdays();
    
    for(int i=0;i<7;i++){
      defaultWeekNames.add(temp[(i)%7+java.util.Calendar.SUNDAY].substring(0, 1));
    }
    
    return defaultWeekNames;
  }
  
  

}




Java Source Code List

com.bonet.example.bonetcalendarviewactivity.CustomDayGridAdapter.java
com.bonet.example.bonetcalendarviewactivity.CustomGridCalendarActivity.java
com.bonet.example.bonetcalendarviewactivity.CustomGridCalendar.java
com.bonet.example.bonetcalendarviewactivity.CustomMonthProvider.java
com.bonet.example.bonetcalendarviewactivity.CustomYearAdapter.java
com.bonet.example.bonetcalendarviewactivity.CustomYearProvider.java
com.bonet.example.bonetcalendarviewactivity.ExampleActivity.java
com.bonet.example.bonetcalendarviewactivity.GridCalendarActivity.java
com.bonet.example.bonetcalendarviewactivity.ListCalendarActivity.java
com.bonet.views.BtCalendarView.java
com.bonet.views.BtCalendar.java
com.bonet.views.BtDate.java
com.bonet.views.BtMonthViewProvider.java
com.bonet.views.BtMonth.java
com.bonet.views.BtYearViewProvider.java
com.bonet.views.DayGridAdapter.java
com.bonet.views.DayListAdapter.java
com.bonet.views.GridBtMonthViewProvider.java
com.bonet.views.ListBtMonthViewProvider.java
com.bonet.views.ListBtYearViewProvider.java
com.bonet.views.MonthListAdapter.java
com.bonet.views.OnDateSelectedListener.java
com.bonet.views.package-info.java