我有一個似乎很奇怪的問題。添加ListView會導致Android應用程序崩潰
我創建的Android應用程序運行良好,但是當我在我的layout.xml
文件中添加了「ListView」元素時。 我仍然沒有在我的java類中使用ListView,應用程序拒絕啓動。 它只是craches,給我這個消息:The application Client (process com.example) has stopped unexpectedly. Please try again.
這是我layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/filename"/>
<ListView android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
/>
<EditText
android:id="@+id/input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
/>
<Button
android:id="@+id/connect"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Connect"
android:onClick="Connect"
/>
<Button
android:id="@+id/download"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Download"
android:onClick="Download"
/>
<Button
android:id="@+id/delete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="List"
android:onClick="List"
/>
</LinearLayout>
注:我的Android設備,而不是模擬器 這裏對測試的一個截圖錯誤我得到的logcat:http://img852.imageshack.us/i/screenshotgg.png/
終於找到了導致它不工作的基石錯誤 我宣佈2個小工具具有相同的ID。
Thnx提前。
請發佈您的'layout.xml' – MByD 2011-04-11 16:05:16
請提供'layout.xml'和錯誤報告/堆棧跟蹤(如果您使用的是Eclipse,可以在DDMS或Debug中找到) – pecka85 2011-04-11 16:06:17
您有''ClassCastException'' onCreate'在'FtpClient.java'中,請發佈你的'onCreate'方法的代碼並指出第42行。 – 2011-04-11 16:43:02