-2

每次遇到这个问题,我都无法解决,有人可以帮帮我吗?

日志猫:

    11-20 12:48:19.842: E/AndroidRuntime(344): FATAL EXCEPTION: main
11-20 12:48:19.842: E/AndroidRuntime(344): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.refreshmedia.nieuwsregio/com.media.news.NewsActivity}: 
                                           java.lang.RuntimeException: Unable to start activity ComponentInfo{com.media.news/com.media.news.Home}:
                                           android.view.InflateException: Binary XML file line #3: Error inflating class Listview
11-20 12:48:19.842: E/AndroidRuntime(344):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
11-20 12:48:19.842: E/AndroidRuntime(344):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-20 12:48:19.842: E/AndroidRuntime(344):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-20 12:48:19.842: E/AndroidRuntime(344):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-20 12:48:19.842: E/AndroidRuntime(344):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 12:48:19.842: E/AndroidRuntime(344):  at android.os.Looper.loop(Looper.java:123)
11-20 12:48:19.842: E/AndroidRuntime(344):  at android.app.ActivityThread.main(ActivityThread.java:3683)
11-20 12:48:19.842: E/AndroidRuntime(344):  at java.lang.reflect.Method.invokeNative(Native Method)
11-20 12:48:19.842: E/AndroidRuntime(344):  at java.lang.reflect.Method.invoke(Method.java:507)
11-20 12:48:19.842: E/AndroidRuntime(344):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-20 12:48:19.842: E/AndroidRuntime(344):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-20 12:48:19.842: E/AndroidRuntime(344):  at dalvik.system.NativeStart.main(Native Method)

这是我的 XML 文件:

<Listview xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/android:list"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="fill_parent">

<TextView android:id="@+id/android:empty"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
  />

</Listview>
4

3 回答 3

4

检查你的大写/小写 - 它应该是ListView,而不是Listview(注意大写V)。

于 2012-11-20T12:38:01.920 回答
1

您不能将 ListView 用作主布局,使用一个主布局并在主布局中添加 Listview 和 textview,并且您不能在 listview 中添加 textview 使用下面的代码。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ListView
        android:id="@+id/android:list"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="fill_parent" 
        android:layout_above="@+id/android:empty" />

    <TextView android:id="@+id/android:empty"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" />

</RelativeLayout>
于 2012-11-20T12:53:22.793 回答
0

您需要在 xml 中添加根视图或布局!

尝试这个

    <?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="fill_parent"
    android:background="@drawable/background"
    android:orientation="vertical" >

<ListView 
android:id="@+id/android:list"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="fill_parent"/>

<TextView android:id="@+id/android:empty"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
  />
</LinearLayout>
于 2012-11-20T12:46:53.180 回答