Tileview how to get current tile

Important: posts that do not use this template will be ignored or closed.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the relevant part of the documentation. We will not respond in detail to posts where you haven’t read the relevant documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.

Description

get position of current tile

What MCU/Processor/Board and compiler are you using?

simulator

What LVGL version are you using?

7.4.0

What do you want to achieve?

for example, i created a tileview with 4 tiles. how to get current tile index or position of current tile?
thank you

What have you tried so far?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

i solved my problem with bellow source code. thank you
if (event == LV_EVENT_VALUE_CHANGED){
print_log(“current tile (%d, %d)\n”, ((lv_tileview_ext_t *)lv_obj_get_ext_attr(obj))->act_id.x, ((lv_tileview_ext_t *)lv_obj_get_ext_attr(obj))->act_id.y);
}

It’s better to use lv_tileview_get_tile_act as it will be more portable across LVGL versions.

1 Like