2011-10-03 3 views
1

아래 코드를 사용하여 목록 항목의 이미지, 제목 및 텍스트 영역의 서식을 지정하는 레이아웃을 만들었습니다.
트위터 응용 프로그램 레이아웃처럼 보이게하려고합니다. 트윗을 어떻게 감쌀 것인지, 어떤 점이 누락 되었습니까?줄임표 표시 대신 줄 바꿈 할 목록 항목 행 가져 오기

플랫폼 세부 정보 : BB OS 5.0

코드 :

protected void sublayout(int width, int height) { 
    try { 
     deleteAll(); 
    } catch (Exception ex) { 

    } 

    MyTitleField lblTitle = new MyTitleField(info.title);//extends LabelField 
    LabelField lblDesc = new LabelField(info.description , LabelField.ELLIPSIS) 
    { 
     protected void layout(int width, int height) { 
      // TODO Auto-generated method stub 
      super.layout(width, height); 
     } 
    }; 

    BitmapField bmfIcon = new BitmapField(info.icon); 
    add(lblTitle); 
    add(lblDesc); 
    add(bmfIcon); 

    int iconHeight = bmfIcon.getBitmapHeight(); 
    int fontHeight = Font.getDefault().getHeight(); 
    int preferredWidth = width;//getPreferredWidth(); 

    int startY = (rowHeight - iconHeight)/2; 
    layoutChild(bmfIcon, bmfIcon.getBitmapWidth(), bmfIcon.getBitmapHeight()); 
    setPositionChild(bmfIcon, 5, startY); 

    int textWidth = preferredWidth - (bmfIcon.getBitmapWidth() +10); 
    int textStartX = bmfIcon.getBitmapWidth() + 10; 
    layoutChild(lblTitle, textWidth , 
      fontHeight + 1); 
    setPositionChild(lblTitle, textStartX, startY); 

    int descHeight = rowHeight - (startY+fontHeight+2); 
    layoutChild(lblDesc, textWidth , descHeight); 

    setPositionChild(lblDesc, textStartX, (startY+fontHeight+2)); 

    setExtent(preferredWidth, getPreferredHeight()); 
} 

My code produces

The desired effect

+0

여기 줄임표 스타일을 제거 할 수없는 생산)' – icchanobot

+0

그래, 할 수있어.하지만 그냥 끝까지 달려서 포장하지 않는다. – Irwin

+0

blakberry-os5 개발을 위해 다운로드해야하는 JDE 버전을 알려 주실 수 있습니까? 나는 인터넷 검색으로 그것을 찾을 수 없다. – Viswa

답변

1
  1. 첫째, 당신은 icchanobot이 제안 줄임표 스타일을 제거 할 필요가 .
  2. 그런 다음 VerticalFieldManager (HorizontalFieldManager도 사용 가능) 내부에 라벨 입력란을 추가해야합니다. 이는 this 답안에서 제안한 것입니다. `레이블 필드 lblDesc = 새로운 레이블 필드 (info.description :
  3. 다음 코드 스 니펫

String longString = "This is a LabelField inside a VerticalFieldManager. Here is a link to your question https://stackoverflow.com/questions/7641753/get-list-item-row-to-wrap-instead-of-show-ellipsis"; 

VerticalFieldManager vfm = new VerticalFieldManager(Manager.USE_ALL_WIDTH | Manager.NO_HORIZONTAL_SCROLL); 
vfm.add(new LabelField(longString)); 
add(vfm); 


enter image description here

관련 문제