我有一个似乎很奇怪的问题。添加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