Android Open Source - DecorateCalendarView Main Activity






From Project

Back to project page DecorateCalendarView.

License

The source code is released under:

Apache License

If you think the Android project DecorateCalendarView 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 net.zaim.decoratecalendarview.sample;
/*w  w  w . j a  v  a 2s. com*/
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.widget.Toast;

import net.zaim.decoratecalendarview.DecorateCalendarView;

import java.text.SimpleDateFormat;
import java.util.Date;


public class MainActivity extends ActionBarActivity implements DecorateCalendarView.OnDecorateCalendarListener {

    private DecorateCalendarView mCalendarView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mCalendarView = (DecorateCalendarView) findViewById(R.id.my_calendar);
        Bundle bundle = new Bundle();
        bundle.putString(DecorateCalendarView.BUNDLE_KEY_SELECTED_COLOR, String.valueOf(getResources().getColor(R.color.select_background)));
        mCalendarView.setOnDecorateCalendarListener(this);
        mCalendarView.initCalendar(getSupportFragmentManager(), bundle);
    }


    @Override
    public void onDayClick(Date day) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Toast.makeText(this, format.format(day), Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onChangeDisplayMonth(Date date) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
        Toast.makeText(this, format.format(date), Toast.LENGTH_SHORT).show();

        // Decorate cell of day
        mCalendarView.setTopTextOnDay(10, "top", Color.parseColor("#00ff00"));
        mCalendarView.setMiddleTextOnDay(10, "middle", Color.parseColor("#ff0000"));
        mCalendarView.setBottomTextOnDay(10, "bottom", Color.parseColor("#0000ff"));
    }
}




Java Source Code List

net.zaim.decoratecalendarview.BaseGridView.java
net.zaim.decoratecalendarview.DecorateCalendarFragment.java
net.zaim.decoratecalendarview.DecorateCalendarPagerAdapter.java
net.zaim.decoratecalendarview.DecorateCalendarView.java
net.zaim.decoratecalendarview.sample.MainActivity.java
net.zaim.decoratecalendarview.view.WrapContentHeightViewPager.java