如何在Android中显示日历视图?

如何在Android中显示日历视图?,android,android-view,android-calendar,Android,Android View,Android Calendar,在我的应用程序中,我需要在上面显示日历和一些事件,如下图所示。 我读过这个主题,但那个里描述的libs不适合我的需要。我还发现了这个lib:,但它只适用于api级别为14或更高的设备,而我需要支持api级别为10的设备 也许有人知道解决这个问题的图书馆?任何帮助都将不胜感激。我引用此链接创建类似的内容 /** *注意:考虑到年、月、日,您需要实现此部分 *当月SQLite数据库中的所有条目。迭代 *列出所有条目,并获取dateCreated,该日期转换为 *一天。 * *@param年 *@

在我的应用程序中,我需要在上面显示日历和一些事件,如下图所示。

我读过这个主题,但那个里描述的libs不适合我的需要。我还发现了这个lib:,但它只适用于api级别为14或更高的设备,而我需要支持api级别为10的设备

也许有人知道解决这个问题的图书馆?任何帮助都将不胜感激。

我引用此链接创建类似的内容

/**
*注意:考虑到年、月、日,您需要实现此部分
*当月SQLite数据库中的所有条目。迭代
*列出所有条目,并获取dateCreated,该日期转换为
*一天。
* 
*@param年
*@param月
*@返回
*/
私有HashMap findNumberOfEventsPerMonth(整数年,整数月)
{
HashMap=newHashMap();
//DateFormat dateFormatter2=新的DateFormat();
//                      
//字符串day=dateFormatter2.format(“dd”,dateCreated).toString();
//
//if(地图容器(日))
// {
//整数val=(整数)map.get(day)+1;
//地图放置(日,瓦尔);
// }
//否则
// {
//地图放置(第1天);
// }
返回图;
}
在上面的代码中,创建包含日期的Hashmap。如果情况如此,则更换(根据您的需要进行更改)

if((mEventsPerMonthMap!=null)&&(!mEventsPerMonthMap.isEmpty()){
Set keys=mEventsPerMonthMap.keySet();
用于(字符串键:键){
如果(键等于(日期+“/”+月日+“/”+年)
&&meventspermontmap.containsKey((String.format(“%02d”,Integer.parseInt(theday)))
+“/”+monthInNo+“/”+theyear)){
datewiseEventmap.put(日期+“/”+月份)不+“/”+年份,
(ArrayList)
meventspermontmap.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()));

            }
if(datewiseEventmap!=null&&datewiseEventmap.size()>0){
mNumEvents=(ArrayList)datewiseEventmap
.获得(日期+“/”+月日+“/”+年);
eventName.setText(sbf);
eventName.setBackgroundResource(R.drawable.appointment\u name\u bg);
//gridcell.setBackgroundResource(R.可绘制日历的详细说明);
eventCount.setVisibility(View.VISIBLE);
//eventCount.setBackgroundResource(R.drawable.Calendar\u详细信息\u描述);
如果(mNumEvents.size()>1){
eventCount.setVisibility(View.VISIBLE);
eventCount.setText(“+”+String.valueOf(mNumEvents.size());
}
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()));

            }