2011-10-03 10 views
1

Iは、画像、タイトル、リスト項目のテキスト領域を書式レイアウトを生成得るために以下のコードを使用するのラップするリスト項目行を取得します。それがラップするつぶやきを取得する方法の面で、私が何をしないのです -
私はそれがTwitterのように見えるように取得したいと思い、レイアウトをアプリ?代わりに表示する省略記号

プラットフォームの詳細: 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

はあなたがここで省略記号スタイルを取り除くことはできません生成します: 'labelFieldプロパティlblDesc =新しいlabelFieldプロパティ(info.description ) ' – icchanobot

+0

ええ、私はすることができますが、それはちょうどすべての方法を実行し、ラップしていません。 – Irwin

+0

は、あなたは私がblakberry-OS5開発にダウンロードする必要がJDEのバージョンを私に伝えることができます?。私はグーグルでそれを見つけることができません – Viswa

答えて

1
  1. まず、あなたはicchanobotが示唆したように省略記号スタイルを取り除く必要があります。
  2. 次に、あなたはthisの答えで提案されているように(HorizontalFieldManagerがあまりにも動作します)VerticalFieldManagerの内側にあなたのラベルフィールドを追加する必要があります。

次のコードスニペット

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

関連する問題