Android 在文本视图中显示指示
在我的应用程序中,我有1个列表视图和4个文本视图作为列视图,因为一些数据有一些重复值,而另一些则不会。因此我必须为那些有重复值的数据提供一个指示图像。因此我有一个想法,在列表视图的第二个文本视图的末尾放置一些小图像。如果我尝试将一些文本视图放置在xml中,并为其设置一些图像,则意味着另一个文本视图(textview 3,4)也是放错地方了。有人有什么想法吗?我也尝试了spannableimage,但没有得到想要的结果。提前谢谢 我所拥有的: 我的列表视图:Android 在文本视图中显示指示,android,textview,Android,Textview,在我的应用程序中,我有1个列表视图和4个文本视图作为列视图,因为一些数据有一些重复值,而另一些则不会。因此我必须为那些有重复值的数据提供一个指示图像。因此我有一个想法,在列表视图的第二个文本视图的末尾放置一些小图像。如果我尝试将一些文本视图放置在xml中,并为其设置一些图像,则意味着另一个文本视图(textview 3,4)也是放错地方了。有人有什么想法吗?我也尝试了spannableimage,但没有得到想要的结果。提前谢谢 我所拥有的: 我的列表视图: 31/7/2012 | gfdhh
31/7/2012 | gfdhh | 78 | 78
我想要的是:
31/7/2012 | gfdhh* | 78 |78.
我的代码:(用于listview)
你在这个跨文本中遇到了什么问题?只有图像显示(R.drawable.up),而不是文本…Imran Khan你删除了你的答案???
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/Layout1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="4dip"
android:paddingBottom="6dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView android:id="@+id/text1"
android:layout_width="80dip"
android:layout_height="wrap_content"
/>
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:background="#FF909090" />
<TextView android:id="@+id/text3"
android:layout_width="60dip"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"/>
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:background="#FF909090" />
<TextView android:id="@+id/text5"
android:layout_width="60dip"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
/>
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:background="#FF909090" />
<TextView android:id="@+id/text7"
android:layout_width="60dip"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
/>
<TextView android:id="@+id/text9"
android:layout_width="60dip"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:visibility="gone"/>
</LinearLayout>
SpannableString ss = new SpannableString(cursor.getString(cursor.getColumnIndex(db.KEY_DESC)));
Drawable d = getResources().getDrawable(R.drawable.up);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BASELINE);
ss.setSpan(span, 0,cursor.getString(cursor.getColumnIndex(db.KEY_DESC)).length() , Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
text3.setText(ss);