prakash .k
prakash .k

Reputation: 635

Image in textview

In My application i am showing data from database in a listview. In that listview i have 4 textviews in columnwise.Now after 2nd textview i have to add 1 image(star) to indicate something.But when i tried to add that all the textviews are going far behind the screen,Without affecting other textview i have to show that.

My display:

30/07/2012 | gfgdh | 78 | 78
30/07/2012 | hjkk  | 45 | 45

What i want is:

30/07/2012 | ghgdh* |78  |78

My Xml code is:

<?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>

Thanks in advance.

Upvotes: 0

Views: 950

Answers (1)

Zain Ali
Zain Ali

Reputation: 15963

You can create a spannableString and place your image where you want in the TextView. Or you can use

ImageSpan is = new ImageSpan(context, resId);
text.setSpan(is, index, index + strLength, 0);

Source

Upvotes: 1

Related Questions