2012-07-30 75 views
0

在我的应用程序中,我显示的是数据库中的数据。在那个列表视图中,我有4个textviews在columnwise.Now后第二个textview我不得不添加1个图像(明星)来表明something.But当我试图补充说,所有的textviews都远远落后于屏幕,不影响其他textview我有以表明这一点。textview中的图像

我显示:

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

我要的是:

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

我的XML代码:

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

在此先感谢。

+0

你把*(星号)和各文本在结束每一次? – 2012-07-30 13:15:54

+0

试试看ImageSpan,它可能会诀窍 - http://developer.android.com/reference/android/text/style/ImageSpan.html 这就是你如何把图像笑脸:)在中间的文字。 – Shark 2012-07-30 13:16:40

+0

如果它满足(复发==真正的)意味着我必须把这个,否则不需要.. – 2012-07-30 13:16:52

回答

1

您可以创建一个spannableString并将图像放置在TextView中的所需位置。或者你可以使用

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

Source

+0

谢谢扎因阿里..你可以说这是什么索引,和strlength? – 2012-07-30 13:24:03

+0

这是范围index_index + strlength在哪里附加标记对象(是)。 – 2012-07-30 13:32:54