2017-02-24 39 views

回答

1

list_item.xml從您發佈只是把所需要的繪製上的TextView右邊的文章:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="55dip" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/lblListItem" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textSize="17dip" 
     android:paddingTop="5dp" 
     android:paddingBottom="5dp" 
     android:drawableRight[End]="@drawable/my_cool_drawable" 
     android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft" /> 
</LinearLayout> 

如果每個項目應該有不同的繪製,然後設置它在運行時,通過使用setCompoundDrawable方法:

txtListChild.setCompoundDrawable(null, null, myCoolDrawable, null); 

您可能需要指定drawablePadding。順便說一句,LinearLayout在文章中的例子是沒用的,你可以用FrameLayout來代替,或者甚至檢查merge標記。

+0

嗨,感謝您的迴應,我在哪個文件中放置了這段代碼? – Spartan123

+0

@ Spartan123通過查看你發佈的文章,我會說在你將數據綁定到子視圖的地方。它是'ExpandableListAdapter.java'中的'getChildView'。您爲孩子設置文字的相同位置。 – nikis

相關問題