【发布时间】:2018-05-08 06:52:36
【问题描述】:
下面是我的页脚布局,用于为我的 ListView 设置它:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_cell_bg">
<TextView
android:text="footer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
一切正常。但是,如果我想在我的 ListView 的页脚中设置一个带有某种背景颜色的空视图怎么办?
如果我按照以下方式进行操作,ListView 不会显示页脚视图。 :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_cell_bg">
</RelativeLayout>
我将页脚设置如下:
View footerView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_for_gym_list, null);
listGymSuggestions.addFooterView(footerView);
请指导我如何在 ListView 中设置一些高度和背景颜色的空页脚?
【问题讨论】:
-
你可以用
View代替RelativeLayout,如果不工作的话,它应该可以工作,让我知道。 -
您必须提供高度属性。没有任何孩子,您的 Layout 作为页脚将不会显示。
-
你知道@PragatiSingh 我给出了相同的答案5,但有人一直在投票,甚至没有说。我哪里做错了??
-
现在他们已经删除了他们的反对票!
-
除此之外,我还拿了一个 SearchView。并且 onCLose() 方法没有调用..或者请。指南 按下 Android SearchView 的 X(close) 图标时如何触发关闭事件?注意:我知道如果我提出新问题会更好。 ;)
标签: java android listview footer