私のアプリケーションでは、列ごとに4つのテキストビューを持つ1つのリストビューがあります。データベースからのデータを表示しています.一部のデータには繰り返し値があり、他のデータにはありません.したがって、繰り返しのあるデータの表示画像が必要です.だから、リストビューの2番目のテキストビューの最後に小さな画像を配置するという考えがあります.xmlにテキストビューを配置して画像を設定しようとすると、他のテキストビュー(textview 3,4)も誰かがこれを行うアイデアを持っていますか.私もspannableimageを試しましたが、望ましい結果が得られませんでした.よろしくお願いします.
私が持っているもの:私のリストビュー:
31/7/2012 | gfdhh | 78 | 78
私が欲しいのは:
31/7/2012 | gfdhh* | 78 |78.
私のコード:(リストビュー用)
<?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);