views:

141

answers:

1

Hi,

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/listViewShow"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:background="@drawable/brown_bg" 
    android:padding = "3dip">

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

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.

Regards

Sunil

+2  A: 

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.

CommonsWare
Thanx a lot. I was inflating using inflate(R.layout.row, null). I changed it to what you suggested and it solved the problem. Thanx again.
sunil