如何显示在Android的日历视图? [英] How to display calendar view in Android?

查看:216
本文介绍了如何显示在Android的日历视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In my application I need to display calendar and some events on it, like on image below.

我读过<一个href=\"http://stackoverflow.com/questions/6080307/how-to-display-a-calendar-ui-in-an-android-application\">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()));

            }

这篇关于如何显示在Android的日历视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆