如何显示在Android的日历视图?
在我的应用程序需要在其上显示日历和一些事件,如下面的图像。
In my application I need to display calendar and some events on it, like on image below.
我读过this话题,但库描述有不适合我的需要。我也发现这个lib目录下:扩展日历视图,但它仅适用于设备与API级别14或更高,而我需要支持API级别10
也许有人知道解决这个问题的一些库?任何帮助将是非常美联社preciated。
I've read this topic, but libs described there doesn't fit my needs. I've also found this lib: Extended Calendar View, but it works only on devices with api level 14 or higher while I need to support api level 10.
Maybe someone know some library for solving this problem? Any help will be highly appreciated.
我称此链接创建类似的东西的链接
i referred this link to create something like that link
/**
* NOTE: YOU NEED TO IMPLEMENT THIS PART Given the YEAR, MONTH, retrieve
* ALL entries from a SQLite database for that month. Iterate over the
* List of All entries, and get the dateCreated, which is converted into
* day.
*
* @param year
* @param month
* @return
*/
private HashMap findNumberOfEventsPerMonth(int year, int month)
{
HashMap map = new HashMap<String, Integer>();
// DateFormat dateFormatter2 = new DateFormat();
//
// String day = dateFormatter2.format("dd", dateCreated).toString();
//
// if (map.containsKey(day))
// {
// Integer val = (Integer) map.get(day) + 1;
// map.put(day, val);
// }
// else
// {
// map.put(day, 1);
// }
return map;
}
在上面的code创建的Hashmap其中包含日期。和替换,如果符合这个条件(根据乌拉圭回合的需求进行更改)
In the above code create Hashmap which contains date. and replace if condition with this(Make changes according to ur needs)
if ((mEventsPerMonthMap != null) && (!mEventsPerMonthMap.isEmpty())) {
Set<String> keys = mEventsPerMonthMap.keySet();
for (String key : keys) {
if (key.equals(theday + "/" + monthInNo+ "/" + theyear)
&& mEventsPerMonthMap.containsKey((String.format("%02d", Integer.parseInt(theday)))
+ "/"+ monthInNo+ "/" + theyear)) {
datewiseEventmap.put(theday + "/" + monthInNo+"/" + theyear,
(ArrayList<Appointment>)
mEventsPerMonthMap.get((String.format("%02d",Integer.parseInt(theday)))+ "/" + monthInNo+ "/" + theyear));}}
更改每个网格单元
if (datewiseEventmap != null && datewiseEventmap.size() > 0) {
mNumEvents = (ArrayList<Appointment>) datewiseEventmap
.get(theday + "/" + monthInNo+ "/" + theyear);
eventName.setText(sbf);
eventName.setBackgroundResource(R.drawable.appointment_name_bg);
//gridcell.setBackgroundResource(R.drawable.calender_details_description);
eventCount.setVisibility(View.VISIBLE);
//eventCount.setBackgroundResource(R.drawable.calender_details_description);
if (mNumEvents.size() > 1) {
eventCount.setVisibility(View.VISIBLE);
eventCount.setText("+ " + String.valueOf(mNumEvents.size()));
}