Android的列表视图格式的文本 [英] Android Listview format text

查看:113
本文介绍了Android的列表视图格式的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是有可能的格式在ListView中的项目文本,以便它看起来如这样的:

is it possible to format an item text in the Listview so it would look for example like this:

字符串的一部分是粗体并部分不是

感谢

推荐答案

是啊,你就必须有两个不同的textviews,一个大胆的文字,以及一个用于文本不用粗体。所以你有看起来像这样的每一行的布局:

Yea, you'd just have to have two different textviews, one for the bold text, and one for the unbolded text. So you'd have a layout for each row that looks like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="horizontal"
>
   <TextView android:id="@+id/bold_field"
     android:layout_width="wrap_content"
     android:layout_height="fill_parent"
     android:textStyle="bold"
   />
   <TextView android:id="@+id/non_bold_field"
     android:layout_width="wrap_content"
     android:layout_height="fill_parent"
   />
</LinearLayout>

然后你会使用 SimpleAdapter 映射适当件串到每个TextView的。如果你希望字符串显得浑然一体,你可能不得不用的重力的TextViews的。

Then you'd use a SimpleAdapter to map the appropriate pieces of the string to each TextView. If you want the string to appear seamless, you'll probably have to mess around with the gravity of the TextViews.

这篇关于Android的列表视图格式的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆