【问题标题】:codename one clickable component代号一个可点击的组件
【发布时间】:2016-09-12 11:19:15
【问题描述】:

我想让一个组件可点击。我正在使用这种方法: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;

                }

但是,当我运行它时,容器仍然无法点击。如何解决?

【问题讨论】:

    标签: events button containers codenameone


    【解决方案1】:

    MultiButton 已经是领先组件。您应该设置一个常规的Button 或任何不派生Container 的组件作为您的领导。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-11
      • 2014-01-24
      • 1970-01-01
      • 2019-05-28
      相关资源
      最近更新 更多