2011-10-20 17 views
0

我想爲我的ListView創建一個CustomItem,並且我的String文本有問題。我嘗試使用字符「\ n」替換換行。Bada:ListView中的CustomItem

創建我的字符串這樣的:

String fullName ="First Name: "; 
    fullName.Append(firstName);//one string variable 
    fullName.Append("\n"); 
    fullName.Append("Last Name: "); 
    fullName.Append(lastName);//one string variable 

我想要的lastName和名字在不同的線路出現了。

我把這個字符串放在我的自定義項目中: pCitem-> AddElement(Osp :: Graphics :: Rectangle(10,-30,430,150),index,fullName,35,Osp :: Graphics :: Color :: COLOR_GREEN,OSP ::顯卡::顏色:: COLOR_RED,真正的);

(API在這裏:http://developer.bada.com/help_2.0/index.jsp?topic=/com.osp.cppapireference.help/classOsp_1_1Ui_1_1Controls_1_1CustomItem.html)。

我的問題是,firstName和lastName沒有出現在不同的行中。我如何解決這個問題?謝謝

回答

0

您可以添加兩個字符串,一個名字和另一個姓氏如下所示。其中矩形()函數包含不同的座標。

String firstName(L"First Name: "); 
firstName.Append("first name"); 

String lastName(L"Last Name: "); 
lastName.Append("last name"); 

pCitem->AddElement(Rectangle(10,30,430,150),index,firstName,35,Osp::Graphics::Color::COLOR_GREEN,Osp::Graphics::Color::COLOR_RED,true); 
pCitem->AddElement(Rectangle(10,65,430,150),index,lastName,35,Osp::Graphics::Color::COLOR_GREEN,Osp::Graphics::Color::COLOR_RED,true); 
1

,你只用於允許插入一個單一的行字符串的的addElement()方法。 對於多行字符串,你必須創建一個EnrichedText支持上 多行文本和使用:

result CustomItem::AddElement (const Osp::Graphics::Rectangle &rect, 
           int elementId, 
           const Osp::Graphics::EnrichedText &text) 

方法將其插入到你的定製項目

希望這會有所幫助!

相關問題