【发布时间】:2021-06-02 12:34:10
【问题描述】:
我从 sqlite 数据库中获取数据。我想要的是用粗体显示我的每个产品的“名称”。
代码如下:
fullProductDetails = "<b>Name: </b>"+data.getString(1) + "| Price: " + data.getString(2) + "| Quantity: " + data.getString(3);
问题是它在我的列表视图中显示的是“b”字符而不是粗体。
更新
这里还有一些代码:
Cursor data = mDatabaseHelper.getData();
ArrayList<String> listData = new ArrayList<>();
while (data.moveToNext()) {
//get the value from the database in column 1
//then add it to the ArrayList
totalPrice=Float.parseFloat(data.getString(2))*Float.parseFloat(data.getString(3));
fullProductDetails = "<b>Name: </b>"+data.getString(1) + "| Price: " + data.getString(2) + "| Quantity: " + data.getString(3);
listData.add(fullProductDetails+" <b>Total Price: </b>"+totalPrice);
}
//create the list adapter and set the adapter
ListAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, listData);
mListView.setAdapter(adapter);
【问题讨论】:
-
你能提供截图和更多代码吗?
-
@Renis1235 我已经更新了。让我知道你是否更清楚!
-
你如何将元素添加到列表中,你也可以包括那个吗?