我的表单中有一个带有2个标签的Tabs容器。第一个选项卡有一个列表,单击列表项时,第二个选项卡将使用setSelectedIndex滚动到。首先,标签不可滚动。但是,当第二个选项卡被刷到。我希望标签变为可滚动,以便允许用户使用滑动手势返回。所以我最初将swipeActivated设置为false,然后当单击列表项时,我尝试将setSwipeActivated设置为true,然后重新验证表单,但是当我运行应用程序时,这不会激活滑动手势。这是我的代码。
在应用程序打开时调用:
public void setUpMainPage() {
mainForm = (Form) u.createContainer(theme, "MainPage");
Tabs mainTabs = (Tabs) u.findByName("MainTabs", mainForm);
mainTabs.setAnimateTabSelection(false);
mainTabs.setSwipeActivated(false);
findContainer = (Container) u.findByName("GridContainer",
mainForm);
setUpFindContainer();
setUpMibrand();
setUpVouchers();
setUpHomePage();
findTabs = (Tabs) u.findByName("FindTabs", mainForm);
findTabs.hideTabs();
findTabs.setSwipeActivated(false);
insideTabs = (Tabs) u.findByName("InsideTabs", mainForm);
insideTabs.hideTabs();
insideTabs.setSwipeActivated(false);
homeTabs = (Tabs) u.findByName("HomeTabs", mainForm);
homeTabs.hideTabs();
homeTabs.setSwipeActivated(false);
mainForm.show();
}
列表项的ActionListener:
class findActionListener implements ActionListener {
String[] categoryList = {"Shopping Malls", "Food & Dining", "Clothing & Accessories", "Grocery Stores",
"Nightlife & Drinks", "Electronics", "Fitness & Health", "Travel & Hotels",
"Activities & Events", "Sports Gear", "House & Home", "Baby & Kids", "Beauty & Spa", "Motoring", "Liquor Stores", "More"};
int index;
Label categoryLabel;
public findActionListener(int i, Label catLabel) {
index = i;
categoryLabel = catLabel;
}
public void actionPerformed(ActionEvent evt) {
findTabs.setSelectedIndex(1, true);
//I set the swipe activated to true on click. Before I switch
//tabs
findTabs.setSwipeActivated(true);
categoryLabel.setText(categoryList[index]);
setUpFindList(categoryList[index]);
mainForm.revalidate();
}
}
我做错了什么或者我想要达到的目标是不可能的?
答案 0 :(得分:0)
检查选项卡的GUI构建器UI中是否取消选中swipeActivated。
还要确保未达到调用setSwipeActivated为true的任何代码。