问题描述
在Codenameone应用中,我正在尝试开发一个在底部具有缩略图列表的轮播。我已经使用Tabs控件在表单中心以轮播样式显示文件(具有差异类型,如图像,视频,文本,按钮等),另一个Tabs控件在底部显示了缩略图图像(第一个轮播文件的缩略图)的形式。当用户在底部轮播中选择缩略图时,相应的组件应显示在第一个轮播中。
In a Codenameone app, I'm trying to develop a carousel with a thumbnail list at the bottom. I've used Tabs control to display files (of diff types like images, video, text, button etc) in carousel style in the center of a form and another Tabs control to display thumbanail images (of the first carousel files) at the bottom of the form. When a user selects a thumbnail image in the bottom carousel, corresponding component should be displayed in the first carousel.
hi.add(BorderLayout.CENTER, mainCarousel);
hi.add(BorderLayout.SOUTH, bottom_tab);
bottom_tab.addSelectionListener((i1, i2) -> {
// bottom_tab.getTabComponentAt(i2).addPointerPressedListener((i) -> {
mainCarousel.getTabComponentAt(i2).setVisible(true);
mainCarousel.getTabComponentAt(i2).repaint();
// });
});
但该组件未显示在中央转盘中。
另外,我尝试捕获事件addPointerPressedListener,但是当我选择缩略图时它没有被触发。
But the component not getting displayed in the central carousel.Also, I tried to capture the event addPointerPressedListener, but it's not getting fired when I select a thumbnail image.
推荐答案
不能将选项卡组件设置为可见/不可见以显示/隐藏它们。那行不通。我猜测您想要的是底部UI的水平列表,类似于答案。
You can't set tab components to visible/invisible to show/hide them. That won't work. I'm guessing that what you want is a horizontal list for the bottom UI similar to the answer here.
我建议使用始终释放的指针。请注意,这只会传递给可聚焦的组件或表单。为了确保获得该事件,可以在表单上注册一个指针释放侦听器。
I would suggest using pointer released always. Notice that this will only get delivered to focusable components or the form. To make sure you get the event you can register a pointer release listener on the form.
这篇关于底部带有缩略图的轮播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!