本文介绍了我得到了致命的例外:当我启动我的应用程序时主要如何修复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi dudes
i在类文件中有这个代码:
hi dudes
i have this code in class file:
ublic class MainActivity extends ListActivity {
DBAdapter db;
List <Story> storyList;
ListView lvMain;
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.i("#%%%%%%%%%%%%%%%%%%%%%","1");
super.onCreate(savedInstanceState);
Log.i("#%%%%%%%%%%%%%%%%%%%%%","1.5");
setContentView(R.layout.activity_main2);
Log.i("#%%%%%%%%%%%%%%%%%%%%%","2");
db.open();
storyList=db.GetAllItems();
Log.i("#%%%%%%%%%%%%%%%%%%%%%","3");
if (storyList.size()==0)//import database if local database is empty.
{
Log.i("#%%%%%%%%%%%%%%%%%%%%%","4");
InputStream sourcePath;
OutputStream destPath;
try {
sourcePath = getBaseContext().getAssets().open("StoryDB");
destPath=new FileOutputStream( "/data/data/"+getPackageName()+"/databases/data");
Log.i("#%%%%%%%%%%%%%%%%%%%%%","5");
CopyDB(sourcePath,destPath);
Log.i("#%%%%%%%%%%%%%%%%%%%%%","5.5");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.i(DBAdapter.TAG,"@@@DB copy finished.");
storyList=db.GetAllItems();
}
}
和xml文件(activity_main)我有这个:
and in xml file (activity_main) i have this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button1"
android:layout_toRightOf="@+id/button1"
android:text="Button" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button2"
android:layout_toRightOf="@+id/button2"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="25dp"
android:text="Button" />
<ListView
android:id="@+id/lvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_below="@+id/button1"
android:layout_marginTop="14dp" >
</ListView>
</RelativeLayout>
现在我想开始我得到这个错误:
now i wanna start that i get this error:
02-14 21:06:57.715: W/ActivityThread(19498): Application behnam.mohammadi.book1 can be debugged on port 8100...
02-14 21:06:57.745: I/#%%%%%%%%%%%%%%%%%%%%%(19498): 1
02-14 21:06:57.745: I/#%%%%%%%%%%%%%%%%%%%%%(19498): 1.5
02-14 21:06:57.815: D/AndroidRuntime(19498): Shutting down VM
02-14 21:06:57.815: W/dalvikvm(19498): threadid=1: thread exiting with uncaught exception (group=0x40f922a0)
02-14 21:06:57.835: E/AndroidRuntime(19498): FATAL EXCEPTION: main
02-14 21:06:57.835: E/AndroidRuntime(19498): java.lang.RuntimeException: Unable to start activity ComponentInfo{behnam.mohammadi.book1/behnam.mohammadi.book1.MainActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
02-14 21:06:57.835: E/AndroidRuntime(19498): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
02-14 21:06:57.835: E/AndroidRuntime(19498): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
02-14 21:06:57.835: E/AndroidRuntime(19498): at android.app.ActivityThread.access$600(ActivityThread.java:140)
02-14 21:06:57.835: E/AndroidRuntime(19498): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
02-14 21:06:57.835: E/AndroidRuntime(19498): at android.os.Handler.dispatchMessage(Handler.java:99)
02-14 21:06:57.835: E/AndroidRuntime(19498): at android.os.Looper.loop(Looper.java:137)
02-14 21:06:57.835: E/AndroidRuntime(19498): at android.app.ActivityThread.main(ActivityThread.java:4898)
02-14 21:06:57.835: E/AndroidRuntime(19498): at java.lang.reflect.Method.invokeNative(Native Method)
02-14 21:06:57.835: E/AndroidRuntime(19498): at java.lang.reflect.Method.invoke(Method.java:511)
02-14 21:06:57.835: E/AndroidRuntime(19498): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
02-14 21:06:57.835: E/AndroidRuntime(19498): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
02-14 21:06:57.835: E/AndroidRuntime(19498): at dalvik.system.NativeStart.main(Native Method)
02-14 21:06:57.835: E/AndroidRuntime(19498): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
02-14 21:06:57.835: E/AndroidRuntime(19498): at android.app.ListActivity.onContentChanged(ListActivity.java:243)
02-14 21:06:57.835: E/AndroidRuntime(19498): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:311)
02-14 21:06:57.835: E/AndroidRuntime(19498): at android.app.Activity.setContentView(Activity.java:1924)
02-14 21:06:57.835: E/AndroidRuntime(19498): at behnam.mohammadi.book1.MainActivity.onCreate(MainActivity.java:30)
02-14 21:06:57.835: E/AndroidRuntime(19498): at android.app.Activity.performCreate(Activity.java:5206)
02-14 21:06:57.835: E/AndroidRuntime(19498): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
02-14 21:06:57.835: E/AndroidRuntime(19498): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
02-14 21:06:57.835: E/AndroidRuntime(19498): ... 11 more
推荐答案
这篇关于我得到了致命的例外:当我启动我的应用程序时主要如何修复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!