codename 一个可点击的组件
codename one clickable component
我想让一个组件可以点击。我正在使用这种方法:https://groups.google.com/forum/#!topic/codenameone-discussions/hfVoqRwd9lI(创建一个具有自定义样式的组件,并将多按钮设置为该容器中的主要组件)。
这是我的代码:
Component[] listingsToAdd = new Component[listings.size()];
for (int iter = 0; iter < listingsToAdd.length; iter++) {
MultiButton mb = new MultiButton();
final Map<String, Object> currentListing = listings.get(iter);
Container c = new Container(new BoxLayout((BoxLayout.Y_AXIS)));
String guid = (String) currentListing.get("seq").toString();
Label date = new Label((String) currentListing.get("dt"));
Label name = new Label((String) currentListing.get("name"));
Label startMt = new Label((String) currentListing.get("start_mt"));
Label place = new Label((String) currentListing.get("place"));
Label description = new Label((String) currentListing.get("description"));
c.add(date).add(name).add(startMt).add(place).add(description);
mb.addActionListener(evt
-> showScheduleDetails(searchResults, currentListing));
c.setLeadComponent(mb);
listingsToAdd[iter] = c;
}
但是,当我 运行 它时,容器仍然无法点击。如何解决?
MultiButton
已经是主要组件。您应该设置一个常规 Button
或任何不派生 Container
的组件作为您的引导。
我想让一个组件可以点击。我正在使用这种方法:https://groups.google.com/forum/#!topic/codenameone-discussions/hfVoqRwd9lI(创建一个具有自定义样式的组件,并将多按钮设置为该容器中的主要组件)。 这是我的代码:
Component[] listingsToAdd = new Component[listings.size()];
for (int iter = 0; iter < listingsToAdd.length; iter++) {
MultiButton mb = new MultiButton();
final Map<String, Object> currentListing = listings.get(iter);
Container c = new Container(new BoxLayout((BoxLayout.Y_AXIS)));
String guid = (String) currentListing.get("seq").toString();
Label date = new Label((String) currentListing.get("dt"));
Label name = new Label((String) currentListing.get("name"));
Label startMt = new Label((String) currentListing.get("start_mt"));
Label place = new Label((String) currentListing.get("place"));
Label description = new Label((String) currentListing.get("description"));
c.add(date).add(name).add(startMt).add(place).add(description);
mb.addActionListener(evt
-> showScheduleDetails(searchResults, currentListing));
c.setLeadComponent(mb);
listingsToAdd[iter] = c;
}
但是,当我 运行 它时,容器仍然无法点击。如何解决?
MultiButton
已经是主要组件。您应该设置一个常规 Button
或任何不派生 Container
的组件作为您的引导。