【发布时间】:2014-09-17 10:29:48
【问题描述】:
我正在编写一个应用程序,但遇到了一些问题。 使用布局文件时,我在 ViewFlipper 中有 2 个 RelativeLayouts。
这个想法是这个页面特别是一个欢迎屏幕。第一个RelativeLayout“欢迎”您使用应用程序,按下按钮后,用户将被引导到第二个RelativeLayout。在此布局中,有一个搜索栏允许用户搜索特定条件(特定于应用程序,不重要),然后将结果显示在 ListView 中。
一切正常,但显示 ListView 似乎有一些问题。适配器设置正确,我在测试布局中的另一个 ListView 上测试了该方法,它工作正常。然而,RelativeLayout 中的 ListView 似乎有些问题。这是布局代码
activity_welcome.xml
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/welcomeFlipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:animateLayoutChanges="true"
android:background="@color/white"
tools:context="com.jacemcpherson.announcer.WelcomeActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:padding="40dp">
...
<!-- This code irrelevant, all's well :) -->
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="@color/white"
android:padding="40dp">
<TextView
android:id="@+id/textFirstThingsFirst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textYouNeedToSearch"
android:layout_centerHorizontal="true"
android:text="@string/first_things_first"
android:textColor="@color/app_color"
android:textSize="32sp" />
<TextView
android:id="@+id/textYouNeedToSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:gravity="center"
android:text="@string/you_need_to_search_for_your_school"
android:textColor="@color/black"
android:textSize="18sp" />
<EditText
android:id="@+id/schoolSearchEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textYouNeedToSearch"
android:hint="@string/search_hint" />
<ProgressBar
android:id="@+id/searchListProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/schoolSearchEditText"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:visibility="gone" />
<!-- This is the problem area -->
<ListView
android:id="@+id/searchResultsList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/schoolSearchEditText" />
</RelativeLayout>
</ViewFlipper>
我正在设置适配器正常工作,但以防万一我错过了什么,这是 that...
的代码行mListView.setAdapter(new ArrayAdapter<String>(
mContext,
android.R.layout.simple_list_item_1,
result // this is the array of results to be displayed in the list.
));
感谢您的帮助,如果我遗漏了某些事情,在没有进一步信息的情况下无法回答,请告诉我。
【问题讨论】:
-
您能否详细说明“ListView 似乎有问题”?
标签: android listview android-relativelayout