欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

java制作android 日歷代碼分享

 更新時(shí)間:2015年03月19日 15:34:17   投稿:hebedich  
本文給大家分享的是一段使用java制作Android日歷的代碼,非常簡(jiǎn)單實(shí)用,實(shí)現(xiàn)了讀取日歷事件、插入事件、編輯日歷事件、查看日歷等功能,有需要的小伙伴參考下

代碼很簡(jiǎn)單,就不多廢話(huà)了

復(fù)制代碼 代碼如下:

//讀取日歷事件
    public static void getCalendarInfo(Activity activity,String tag){
        String[] projection = new String[]{CalendarContract.Events._ID,CalendarContract.Events.TITLE};
        ContentResolver cr = activity.getContentResolver();
        Cursor cursor = cr.query(CalendarContract.Events.CONTENT_URI, projection, null, null, null);
        int idIndex = cursor.getColumnIndexOrThrow(CalendarContract.Events._ID);
        Log.d(tag, cursor.getCount()+"");
        int titleIndex = cursor.getColumnIndexOrThrow(CalendarContract.Events.TITLE);
        while (cursor.moveToNext()) {
            String id = cursor.getString(idIndex);
            String title = cursor.getString(titleIndex);
            Log.d(tag, id+":"+title);
        }
        cursor.close();
    }
    //插入事件
    public static void addCalendarEvent(Activity activity,String tag){
        Intent intent = new Intent(Intent.ACTION_INSERT,CalendarContract.Events.CONTENT_URI);
        Log.d(tag, CalendarContract.Events.CONTENT_URI.toString());
        intent.putExtra(CalendarContract.Events.TITLE, "Launch");
        intent.putExtra(CalendarContract.Events.DESCRIPTION, "Launch,Android app");
        intent.putExtra(CalendarContract.Events.EVENT_LOCATION, "baidu.com");
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, calendar.getTimeInMillis());
        intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);
        activity.startActivity(intent);
    }
    //編輯日歷事件
    public static void editCalendarEvent(Activity activity,String tag){
        long rowId = 1;
        Uri editUri = ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI,rowId);
        Log.d(tag, CalendarContract.Events.CONTENT_URI.toString());
        Intent intent = new Intent(Intent.ACTION_EDIT,editUri);
        intent.putExtra(CalendarContract.Events.EVENT_LOCATION, "NJ");
        Calendar calendar = Calendar.getInstance();
        calendar.set(2015, 2, 17, 12, 1, 1);
        intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, calendar.getTimeInMillis());
        intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);
        activity.startActivity(intent);
    }
    //查看日歷
    public static void viewCalendar(Activity activity,String tag){
        Calendar calendar = Calendar.getInstance();
        calendar.set(2015, 2, 17, 12, 1, 1);
        Uri uri = Uri.parse("content://com.android.calendar/time/"+calendar.getTimeInMillis());
        Intent intent = new Intent(Intent.ACTION_VIEW,uri);
        activity.startActivity(intent);
    }

以上就是本文給大家分享的全部代碼了,希望對(duì)大家學(xué)習(xí)java能夠有所幫助。

相關(guān)文章

  • Java網(wǎng)絡(luò)編程之基于TCP協(xié)議

    Java網(wǎng)絡(luò)編程之基于TCP協(xié)議

    本文主要將Java基于TCP的網(wǎng)絡(luò)編程主要分解成5個(gè)功能:功能分解1:單向通信功能分解,2:雙向通信功能分解,3:對(duì)象流傳送功能分解,4:加入完整的處理異常方式功能分解,5:多線(xiàn)程接收用戶(hù)請(qǐng)求,需要的朋友可以參考下
    2021-05-05
  • Java?Main?函數(shù)啟動(dòng)不退出的解決方案

    Java?Main?函數(shù)啟動(dòng)不退出的解決方案

    這篇文章主要介紹了Java?Main?函數(shù)啟動(dòng)不退出的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-05-05
  • Java中的HashSet、LinkedHashSet集合解析

    Java中的HashSet、LinkedHashSet集合解析

    這篇文章主要介紹了Java中的HashSet、LinkedHashSet集合解析,與HashSet不同的是,LinkedHashSet在內(nèi)部使用了一個(gè)雙向鏈表來(lái)維護(hù)元素的順序,因此它可以保持元素的插入順序,這使得LinkedHashSet在需要保持元素順序的場(chǎng)景下非常有用,需要的朋友可以參考下
    2023-11-11
  • 詳解Spring?中?Bean?對(duì)象的存儲(chǔ)和取出

    詳解Spring?中?Bean?對(duì)象的存儲(chǔ)和取出

    由于?Spring?擁有對(duì)象的管理權(quán),所以我們也需要擁有較為高效的對(duì)象存儲(chǔ)和取出的手段,下面我們來(lái)分別總結(jié)一下,對(duì)Spring?中?Bean?對(duì)象的存儲(chǔ)和取出知識(shí)感興趣的朋友跟隨小編一起看看吧
    2022-11-11
  • 動(dòng)態(tài)配置Spring Boot日志級(jí)別的全步驟

    動(dòng)態(tài)配置Spring Boot日志級(jí)別的全步驟

    這篇文章主要給大家介紹了關(guān)于動(dòng)態(tài)配置Spring Boot日志級(jí)別的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Spring Boot具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • Spring boot集中異常處理方法實(shí)例

    Spring boot集中異常處理方法實(shí)例

    這篇文章主要介紹了Spring boot集中異常處理方法實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-04-04
  • MyBatis-Plus攔截器實(shí)現(xiàn)數(shù)據(jù)權(quán)限控制的示例

    MyBatis-Plus攔截器實(shí)現(xiàn)數(shù)據(jù)權(quán)限控制的示例

    本文主要介紹了MyBatis-Plus攔截器實(shí)現(xiàn)數(shù)據(jù)權(quán)限控制的示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-02-02
  • Spring中的NamespaceHandler接口及相關(guān)軟件包說(shuō)明

    Spring中的NamespaceHandler接口及相關(guān)軟件包說(shuō)明

    這篇文章主要介紹了Spring中的NamespaceHandler接口及相關(guān)軟件包說(shuō)明,NamespaceHandler 接口,DefaultBeanDefinitionDocumentReader 使用該接口來(lái)處理在spring xml 配置文件中自定義的命名空間,需要的朋友可以參考下
    2023-12-12
  • Java設(shè)計(jì)模式之單態(tài)模式(Singleton模式)介紹

    Java設(shè)計(jì)模式之單態(tài)模式(Singleton模式)介紹

    這篇文章主要介紹了Java設(shè)計(jì)模式之單態(tài)模式(Singleton模式)介紹,本文講解了如何使用單例模式、使用單例模式注意事項(xiàng)等內(nèi)容,需要的朋友可以參考下
    2015-03-03
  • Java的MoreSuppliers工具類(lèi)方法解析

    Java的MoreSuppliers工具類(lèi)方法解析

    這篇文章主要介紹了Java的MoreSuppliers工具類(lèi)方法解析,MoreSuppliers類(lèi)是一個(gè)Java工具類(lèi),它提供了一些增強(qiáng)的Supplier函數(shù),使得Supplier執(zhí)行的結(jié)果可以被緩存,真正的調(diào)用只執(zhí)行一次,需要的朋友可以參考下
    2024-01-01

最新評(píng)論