2010-04-22 107 views
2

在Android中動態加載列表視圖時佈局不正確顯示?

<TextView 
     android:id = "@+id/txtBabbleListTitle" 
    android:layout_width = "wrap_content" 
    android:layout_height = "wrap_content" 
    android:textColor = "#000000"  
     android:text = "New Babble has been put up." > 
    </TextView> 

    <TextView 
     android:id = "@+id/txtBabbleDateTime" 
    android:layout_width = "wrap_content" 
    android:layout_height = "wrap_content" 
    android:layout_alignParentBottom = "true" 
    android:textColor = "#000000"  
    android:text = "2010-04-10 09:47:42" > 
    </TextView> 

    <TextView 
     android:id = "@+id/txtBabbleTotalReplies" 
     android:layout_width = "wrap_content" 
    android:layout_height = "wrap_content" 
    android:layout_alignParentRight = "true" 
    android:textColor = "#000000"  
     android:text = "(7)" > 
    </TextView> 
</RelativeLayout> 

這是我在我適配器充氣的佈局。一切都顯示出來了,但是隻有第二個應該顯示在底部的textview纔會顯示在頂部。有人能讓我知道這個問題嗎?

我我在Eclipse的佈局選項卡中查看它然後它顯示正常。只有動態提取文本時纔會出現問題。

回答

3

你不指出你是如何「在適配器膨脹」。

如果你正在做的是自己通過LayoutInflater,一定要使用inflate(R.layout.row, parent, false),其中R.layout.row是匹配你有上面的XML佈局資源,parentListView(被傳遞到getView()newView(),你在哪裏做通貨膨脹)。如果您不使用inflate()方法的此特定版本,則RelativeLayout將不能很好地用作行容器。

+0

非常感謝。我正在充氣使用充氣(R.layout.row,null)。我改變了你的建議,並解決了問題。再次感謝。 – sunil 2010-04-22 12:29:31