0

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.

prakash .k
  • 635
  • 2
  • 12
  • 24
  • Are you putting * (asterisk) each and every time at end of text ? – Chintan Raghwani Jul 30 '12 at 13:15
  • Try looking at ImageSpan, it might do the trick - http://developer.android.com/reference/android/text/style/ImageSpan.html That's how you'd put a image smiley :) right in the middle of the text. – Shark Jul 30 '12 at 13:16
  • IF it satisfies (recurrence == true) means i have to put that,otherwise no need.. – prakash .k Jul 30 '12 at 13:16

1 Answers1

1

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

Community
  • 1
  • 1
Zain Ali
  • 15,535
  • 14
  • 95
  • 108