Android RelativeLayout中的ListView未显示
我正在写一份申请书,遇到了一点问题。 使用布局文件时,我在视图翻转器的内部有一个2RelativeLayouts 我们的想法是,这个页面尤其是一个受欢迎的屏幕。第一个RelativeLayout“欢迎”您使用该应用程序,按下按钮后,用户将被引导到第二个RelativeLayout。在此布局中有一个搜索栏,允许用户搜索特定条件(特定于应用程序,不重要),然后在列表视图中显示结果 一切正常,但显示ListView似乎有一些问题。适配器设置正确,我在测试布局中的另一个ListView上测试了该方法,效果很好。然而,RelativeLayout中的ListView似乎有问题。这是布局代码 活动\u welcome.xmlAndroid RelativeLayout中的ListView未显示,android,listview,android-relativelayout,Android,Listview,Android Relativelayout,我正在写一份申请书,遇到了一点问题。 使用布局文件时,我在视图翻转器的内部有一个2RelativeLayouts 我们的想法是,这个页面尤其是一个受欢迎的屏幕。第一个RelativeLayout“欢迎”您使用该应用程序,按下按钮后,用户将被引导到第二个RelativeLayout。在此布局中有一个搜索栏,允许用户搜索特定条件(特定于应用程序,不重要),然后在列表视图中显示结果 一切正常,但显示ListView似乎有一些问题。适配器设置正确,我在测试布局中的另一个ListView上测试了该方法,效
<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>
...
我正在设置适配器,使其正常工作,但为了防止我遗漏了什么,下面是的代码行,
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.
));
mListView.setAdapter(新阵列适配器(
McContext,
android.R.layout.simple\u list\u item\u 1,
结果//这是要在列表中显示的结果数组。
));
谢谢你的帮助,如果我错过了一些东西,在没有进一步信息的情况下无法回答,请告诉我 将
布局高度
从包装内容
更改为匹配父项
或填充父项
这一点解释得很好。您能详细说明一下“ListView似乎有问题吗”?我建议您只说
match\u parent
,因为fill\u parent
不受欢迎,非常感谢!这解决了问题。