【发布时间】:2014-06-05 00:39:32
【问题描述】:
我在使用页脚时遇到了一些尴尬的问题。 我有一个在页面中加载的自定义项目列表。当您到达最后一个项目时,它会检索更多可用的项目,即(在等待时)页脚膨胀说“正在下载”。当然,在项目下载后它会被删除。 问题是我膨胀页脚的方式只能在肖像模式下正常工作。使用横向时,页脚不会出现。
编辑:问题是在活动中更改模式(风景、肖像)时。如果我从一开始就以横向开始,它也可以。
这是我用来膨胀页脚的代码:
lv = (ListView) findViewById(R.id.shops_list);
footerView = getLayoutInflater().inflate(R.layout.footer_downloading, null, false);
lv.addFooterView(footerView);
这是布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ListActivity"
android:background="@color/background" >
<ProgressBar android:indeterminate="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progress_list"
style="?android:attr/progressBarStyle"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminateBehavior="cycle" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone"
android:id="@+id/generic_shops_list"
android:background="@color/background" >
<ListView
android:id="@+id/shops_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:divider="@color/pallette_blue"
android:dividerHeight="1dp" />
</LinearLayout>
</RelativeLayout>
这是页脚:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dip" >
<TextView
android:id="@+id/message_downloading_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="@string/downloading_more"
android:textSize="22sp"
android:textStyle="bold"
android:clickable="false"
android:layout_centerInParent="true" />
<ProgressBar android:indeterminate="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progress_downloading"
style="?android:attr/progressBarStyle"
android:indeterminateBehavior="cycle"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/message_downloading_more"
android:layout_marginLeft="15dip" />
</RelativeLayout>
这是完整的课程,也可以参考:Class
【问题讨论】:
标签: android android-layout footer layout-inflater landscape-portrait