当前位置:网站首页>LVGL8.2 Simple Checkboxes
LVGL8.2 Simple Checkboxes
2022-06-30 10:53:00 【Fairy sword love】
Event callback function
static void event_handler(lv_event_t* e)
{
lv_event_code_t code = lv_event_get_code(e); // Get the event code of the response object
lv_obj_t* obj = lv_event_get_target(e); // Get the object that responds to the event
if (code == LV_EVENT_VALUE_CHANGED) {
// Process value changed event
const char* txt = lv_checkbox_get_text(obj); // Get event object checkbox Text content of
const char* state = lv_obj_get_state(obj) & LV_STATE_CHECKED ? "Checked" :"Unchecked"; // Get whether the event object is selected
LV_LOG_USER("%s: %s", txt, state); // Print status content
}
}
Create multiple checkbox
static void lv_example_checkbox_1(void)
{
lv_obj_set_flex_flow(lv_scr_act(), LV_FLEX_FLOW_COLUMN); // Current active interface settings LV_FLEX_FLOW_COLUMN Way layout
lv_obj_set_flex_align(lv_scr_act(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); // main axis alignment LV_FLEX_ALIGN_CENTER,cross axis Placement LV_FLEX_ALIGN_START,cross direction alignment LV_FLEX_ALIGN_CENTER
lv_obj_t* cb;
cb = lv_checkbox_create(lv_scr_act()); // establish checkbox object
lv_checkbox_set_text(cb, "Apple"); // Set text content Apple
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL); // Add all events
cb = lv_checkbox_create(lv_scr_act()); // establish checkbox object
lv_checkbox_set_text(cb, "Banana"); // Set text content Banana
lv_obj_add_state(cb, LV_STATE_CHECKED); // Set the selected state
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL); // Add all events
cb = lv_checkbox_create(lv_scr_act()); // establish checkbox object
lv_checkbox_set_text(cb, "Lemon"); // Set text content Lemon
lv_obj_add_state(cb, LV_STATE_DISABLED); // Set up Disabled state
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL); // Add all events
cb = lv_checkbox_create(lv_scr_act()); // establish checkbox object
lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); // Set up CHECKEDTT and Disabled state
lv_checkbox_set_text(cb, "Melon\nand a new line");// Set text content Melon\nand a new line"
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);// Add all events
lv_obj_update_layout(cb); // to update layout
}
Run the renderings
边栏推荐
- LeetCode Algorithm 86. 分隔链表
- 断路器HystrixCircuitBreaker
- Mysql database foundation: TCL transaction control language
- ArcGIS Pro scripting tool (5) - delete duplicates after sorting
- [rust weekly database] num bigint - large integer
- Kernel linked list (general linked list) "list.h" simple version and individual comments
- Matplotlib notes: contour & Contour
- [STL source code analysis] container (to be supplemented)
- 基于HAL库的按键(KEY)库函数
- 【Rust每周一库】num-bigint - 大整数
猜你喜欢
Q-Learning笔记
同事的接口文档我每次看着就头大,毛病多多。。。
nvm、nrm、npx使用(安装、基本命令、参数、curl、wget)
【STL源码剖析】迭代器
Dell et Apple, deux entreprises de PC établies, se sont effondrées rapidement
【深度学习】深度学习检测小目标常用方法
在IPhone12的推理延迟仅为1.6 ms!Snap等详析Transformer结构延迟,并用NAS搜出移动设备的高效网络结构...
Rejuvenated Dell and apple hit each other, and the two old PC enterprises declined rapidly
透過華為軍團看科技之變(五):智慧園區
Retest the cloud native database performance: polardb is still the strongest, while tdsql-c and gaussdb have little change
随机推荐
ArcGIS PRO + PS vectorized land use planning map
Didi open source agile test case management platform!
蚂蚁金服笔试题:需求文档有什么可以量化的【杭州多测师】【杭州多测师_王sir】...
Turn to cartoon learning notes
LVGL 8.2 Image styling and offset
Android 开发面试真题进阶版(附答案解析)
List介绍
CSDN blog operation team 2022 H1 summary
Migrate full RT thread to gd32f4xx (detailed)
Skill combing [email protected] control a dog's running on OLED
【Proteus仿真】Arduino UNO LED模拟交通灯
经典面试题:负责的模块,针对这些功能点你是怎么设计测试用例的?【杭州多测师】【杭州多测师_王sir】...
The performance of arm's new CPU has been improved by 22%, up to 12 cores can be combined, and the GPU is first equipped with hardware optical tracking. Netizen: the gap with apple is growing
MySQL export SQL script file
今晚19:00知识赋能第2期直播丨OpenHarmony智能家居项目之控制面板界面设计
59 websites programmers need to know
Gd32 RT thread RTC driver function
Matplotlib notes: contour & Contour
Anhui "requirements for design depth of Hefei fabricated building construction drawing review" was printed and distributed; Hebei Hengshui city adjusts the pre-sale license standard for prefabricated
【STL源码剖析】容器(待补充)