<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 的布局选项卡中查看此内容,然后它会正确显示。仅当动态获取文本时才会出现此问题。
最佳答案
您没有说明您如何“在适配器中充气”。
如果您自己通过 LayoutInflater
执行此操作,请务必使用 inflate(R.layout.row,parent, false)
,其中 R. layout.row
是与上面的 XML 匹配的布局资源,而 parent
是 ListView
(它被传递到 getView()
或 newView()
,您在其中进行膨胀)。如果您不使用此特定版本的 inflate()
方法,RelativeLayout
将无法很好地用作行容器。
关于android - 在 Android 中动态加载 ListView 时布局无法正确显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2689621/