2013-06-06 44 views
0

在容器中添加图像时列表不滚动。我有一个扩展容器的列表。我使用了两个容器来设置图像字段(左侧)和文本字段(右侧)。而我正在添加文字归档容器列表滚动正确,但在左侧字段中添加图像时,它不滚动请帮助我。感谢您的帮助。在lwuit中扩展容器时不滚动列表

//列表声明

orgNames = new List(tempName); 
      WidgetRenderer listCheckBoxRenderer = new WidgetRenderer(); 
      orgNames.setListCellRenderer(listCheckBoxRenderer);     

      orgNames.setFixedSelection(List.FIXED_TRAIL); 
      organizationDetailsForm.addComponent(orgNames); 
      OrganizationNameListener orgNameList = new OrganizationNameListener(); 
      orgNames.addActionListener(orgNameList); 

//List renderer class 

class WidgetRenderer extends Container implements ListCellRenderer { 
     private Image[] images; 
     private Button orgImgButton; 
     private Image orgImg; 
     private Container contImage, contDet; 
     private Label orgNameLabel, locationLabel, ratingLabel; 

     public WidgetRenderer() { 
      super(); 
      try { 
       setLayout(new BorderLayout()); 
       contDet = new Container(new BoxLayout(BoxLayout.Y_AXIS)); 
       contImage = new Container(); 
       contDet.setScrollableY(true); 
       contImage.setScrollable(true); 
       contDet.setScrollable(true); 
       contImage.setScrollable(true); 
       contDet.setSmoothScrolling(true); 
       contImage.setSmoothScrolling(true); 
       setScrollable(true); 
       setScrollableY(true);   

       orgImgButton = new Button(); 
       orgNameLabel = new Label(); 

       locationLabel = new Label(); 
       Style orgStyle = new Style(); 
       Style locStyle = new Style(); 
       Font font = Font.createSystemFont(Font.FACE_MONOSPACE, 
         Font.STYLE_BOLD, Font.SIZE_MEDIUM); 
       orgStyle.setFont(font); 
       orgNameLabel.setSelectedStyle(orgStyle); 
       orgNameLabel.setPressedStyle(orgStyle); 
       orgNameLabel.setUnselectedStyle(orgStyle); 
       Font font1 = Font.createSystemFont(Font.FACE_MONOSPACE, 
         Font.STYLE_PLAIN, Font.SIZE_SMALL); 
       locStyle.setFont(font1); 

       locationLabel.setSelectedStyle(locStyle); 
       locationLabel.setPressedStyle(locStyle); 
       locationLabel.setUnselectedStyle(locStyle); 
       ratingLabel = new Label(); 
       contImage.addComponent(orgImgButton); 
       contDet.addComponent(orgNameLabel); 
       contDet.addComponent(locationLabel); 
       addComponent(BorderLayout.WEST, contImage); 
       addComponent(BorderLayout.CENTER, contDet); 
      } catch (Exception ex) { 
       System.out.println("ex" + ex.getMessage()); 
      } 
     } 

     public Component getListCellRendererComponent(List list, Object value, 
       int index, boolean isSelected) { 
      // System.out.println("adding names & loc"); 
      setFocus(isSelected); 
      for (int i = 0; i < list.size(); i++) { 
       if (index == i) { 
        orgNameLabel.setText(tempName[i]); 
        locationLabel.setText(districtDesc[i] + "," + townDesc[i]); 
        orgImgButton.setIcon(DefaultLayout.CreateScaledImage(loadImage(thumbnailURL), DefaultLayout.screenWidth()*10/100, DefaultLayout.screenHeight()*9/100)); 
       } 
      } 

      if (isSelected) { 
       getStyle().setBgColor(0x00BFFF); 
       getStyle().setBgTransparency(100); 
      } else { 
       getStyle().setBgTransparency(30); 
      } 
      return this; 
     } 

回答

0

要调用scaled()这是它必须是非常快渲染器中一个非常缓慢的和昂贵的操作。不是一个好主意。不知道这是否回答你的问题,但我建议调查TRAIL标志是否是你问题的原因。