开发者

Layout not displayed properly while dynamically loading a listview in Android?

    <TextView
        android:id = "@+id/txtBabbleListTitle"
    android:la开发者_Python百科yout_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>

This is the layout that I am inflating in the Adapter. Everything is displayed, but only the second textview which should be displayed at the bottom is getting displayed at the top. Can someone let me know the problem with this?

I I view this in the layout tab in Eclipse then it displays properly. The problem occurs only when the text is fetched dynamically.


You don't indicate how you are "inflating in the Adapter".

If you are doing that yourself via a LayoutInflater, be sure to use inflate(R.layout.row, parent, false), where R.layout.row is the layout resource matching the XML you have above, and parent is the ListView (which is passed into getView() or newView(), where you are doing the inflation). If you do not use this specific version of the inflate() method, RelativeLayout will not work well as a row container.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜