0

我想为我的 ListView 创建一个 CustomItem,但我的字符串文本有问题。我尝试将带有字符“\n”的字符串用于换行。

我这样创建我的字符串:

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

我希望 lastName 和 FirstName 出现在不同的行中。

我把这个字符串放在我的自定义项目中: pCitem->AddElement(Osp::Graphics::Rectangle(10,-30,430,150),index,fullName,35,Osp::Graphics::Color::COLOR_GREEN,Osp::图形::颜色::COLOR_RED,true);

(此处的 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 没有出现在不同的行中。我该如何解决这个问题?谢谢

4

2 回答 2

1

您使用的AddElement()方法只允许您插入单行字符串。对于多行字符串,您必须创建一个支持多行文本的EnrichedText并使用:

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

方法将其插入您的CustomItem

希望这可以帮助!

于 2012-02-21T11:12:35.240 回答
0

您可以添加两个字符串,一个带有名字,另一个带有姓氏,如下所示。其中Rectangle()函数包含不同的坐标。

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);
于 2011-10-22T08:26:16.543 回答