1
我想使組件可點擊。我正在使用這種方法:https://groups.google.com/forum/#!topic/codenameone-discussions/hfVoqRwd9lI(用自定義樣式創建一個組件,並將multibutton設置爲該容器中的主要組件)。 這是我的代碼:codename一個可點擊的組件
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;
}
但是,當我運行它,容器仍然無法點擊。如何解決這個問題?
是的,我用按鈕實現,它的工作原理。 – squallbayu