Android ListView 消失 (SDK 2.3.3)
我正在尝试为我的 Android 设备开发应用程序,但似乎遇到了麻烦。我试图在 Activity
顶部放置一个 TextView
(或其他组件),并在其下方放置一个 Listview
。我遇到的问题是,如果布局中不仅仅是 ListView
,它就不会呈现。因此,由于我尝试拥有 TextView
和 ListView
,因此仅显示 TextView
。
我也尝试将 layout_height
设置
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/test_string"/>
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="@array/list_contents" >
</ListView>
</LinearLayout>
为 _wrap\_content_
,但它没有改变任何东西。
I'm attempting to develop an application for my Android device, and I seem to be having trouble. I'm trying to have a TextView
(or another component) at the top of the Activity
, and a Listview
beneath it. The problem that I'm having is that if I have more than just the ListView
in the layout, it doesn't render. So since I'm trying to have a TextView
and ListView
, only the TextView
is being shown.
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/test_string"/>
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="@array/list_contents" >
</ListView>
</LinearLayout>
I have also tried setting the layout_height
to _wrap\_content_
, but it didn't change anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将以下代码添加到您的线性布局中
Add the following code to ur linear layout