操作 Calendar事件

Intent intent = new Intent(Intent.ACTION_VIEW);
//Android 2.2+
intent.setData(Uri.parse("content://com.android.calendar/events/" + String.valueOf(calendarEventID)));  
//Android 2.1 and below.
//intent.setData(Uri.parse("content://calendar/events/" + String.valueOf(calendarEventID)));    
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
        | Intent.FLAG_ACTIVITY_SINGLE_TOP
        | Intent.FLAG_ACTIVITY_CLEAR_TOP
        | Intent.FLAG_ACTIVITY_NO_HISTORY
        | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
context.startActivity(intent);
**
 * Add a calendar event.
 */
private void addCalendarEvent(){
    Context context = getContext();
    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setType("vnd.android.cursor.item/event");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
            | Intent.FLAG_ACTIVITY_SINGLE_TOP
            | Intent.FLAG_ACTIVITY_CLEAR_TOP
            | Intent.FLAG_ACTIVITY_NO_HISTORY
            | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    context.startActivity(intent);
}

/**
 * Edit a calendar event.
 */
private void editCalendarEvent(){
    Context context = getContext();
    long calendarEventID = .....
    intent.setData(Uri.parse("content://com.android.calendar/events/" + String.valueOf(calendarEventID)));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
        | Intent.FLAG_ACTIVITY_SINGLE_TOP
        | Intent.FLAG_ACTIVITY_CLEAR_TOP
        | Intent.FLAG_ACTIVITY_NO_HISTORY
        | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
   context.startActivity(intent);
}
### 关于 `ElCalendar` 组件中的事件 #### 事件概述 在 Vue 3 和 Element Plus 中,`ElCalendar` 提供了几种重要的事件来响应用户的交互操作。这些事件可以帮助开发者捕捉用户的行为并作出相应的逻辑处理。 - **change**: 此事件会在选择的日期发生变化时被触发[^1]。 - **select**: 用户点击某个具体日期时会触发该事件,在范围选择的情况下,每次点击都会触发一次 select 事件。 - **range-change**: 如果启用了范围选择功能 (`range="true"`), 那么当所选的时间区间发生改变的时候就会发出这个信号. #### 实际应用案例 下面是一个简单的例子展示了如何监听上述提到的不同类型的事件: ```html <template> <div class="calendar-container"> <!-- 使用v-on指令绑定自定义事件 --> <el-calendar v-model="selectedDate" @change="handleChange" @select="handleSelect" @range-change="handleRangeChange"></el-calendar> <p>Selected Date: {{ selectedDate }}</p> </div> </template> <script setup lang="ts"> import { ref } from 'vue'; // 定义变量存储选定的日期/日期范围 const selectedDate = ref(null); function handleChange(value){ console.log('Changed to:', value); } function handleSelect(dateOrRange){ if(Array.isArray(dateOrRange)){ console.log('Selected range:', dateOrRange.join('~')); }else{ console.log('Clicked on single day:', dateOrRange); } } function handleRangeChange(range){ console.log('Range changed:', range.start, '~', range.end); } </script> ``` 在这个示例中,通过给 `<el-calendar>` 添加不同的事件处理器(`@event-name="handlerFunctionName"`),可以轻松捕获来自日历控件的各种输入,并执行特定的操作或更新界面状态。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值