我目前正在編寫一個Android項目,但我在我的xml文件中遇到問題。沒有日期選擇器,listview運行良好。但是,當我添加日期選擇器(不編輯java文件)時,listview消失。以下是我的android xml文件:當添加DatePicker時,ListView消失
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/background"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter Date"
android:textColor="@android:color/white"
android:textSize="25sp" />
<DatePicker
android:id="@+id/datePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Confirm" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@android:color/background_dark" >
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false" />
</LinearLayout>
</LinearLayout>
我的xml文件中是否有錯誤?
更新: 我發現,在三星GalaxyŸ二重奏甚至出現與日期選擇器列表視圖,但仍然沒有出現在三星Galaxy Note
試過ScrollView但無濟於事。我也嘗試將DatePicker的高度設置爲10dp,但ListView仍然不顯示。但是,當我刪除Datepicker,甚至增加TextVIew和Button的大小時,ListView出現。 – user1699366 2013-02-18 06:02:16
發現我上面貼出的代碼適用於Samsung Galaxy Y,但不適用於Samsung Galaxy Note。這是什麼意思? – user1699366 2013-02-18 06:03:53
您的父母'LinearLayout'似乎沒有結束標記。這只是一個錯誤複製..或?另外,你不需要將'ListView'包裝在'LinearLayout'中。只需將它作爲父'LinearLayout'的子元素,並將其高度設置爲「wrap_content」。 – Akash 2013-02-18 06:21:49