所以我正在使用教程来创建我的第一个应用程序。我正在使用我的手机作为模拟器(HTC One X 版本 4.0.3 android)我的编码没有错误,但由于某种原因,我得到一个“不幸的是应用程序已停止”。我尝试将它运行的版本从 2.2 更改为 4.0.3,但它们都没有帮助。这是我的错误日志和编码(简单的编码,所以希望很容易修复)
错误日志
06-09 12:37:20.630: D/AndroidRuntime(18583): Shutting down VM
06-09 12:37:20.650: W/dalvikvm(18583): threadid=1: thread exiting with uncaught exception (group=0x40a65228)
06-09 12:37:20.660: E/AndroidRuntime(18583): FATAL EXCEPTION: main
06-09 12:37:20.660: E/AndroidRuntime(18583): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.regoreminder/com.regoreminder.RegoReminderActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class imageview
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2202)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2237)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.app.ActivityThread.access$600(ActivityThread.java:139)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.os.Handler.dispatchMessage(Handler.java:99)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.os.Looper.loop(Looper.java:156)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.app.ActivityThread.main(ActivityThread.java:5005)
06-09 12:37:20.660: E/AndroidRuntime(18583): at java.lang.reflect.Method.invokeNative(Native Method)
06-09 12:37:20.660: E/AndroidRuntime(18583): at java.lang.reflect.Method.invoke(Method.java:511)
06-09 12:37:20.660: E/AndroidRuntime(18583): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-09 12:37:20.660: E/AndroidRuntime(18583): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-09 12:37:20.660: E/AndroidRuntime(18583): at dalvik.system.NativeStart.main(Native Method)
06-09 12:37:20.660: E/AndroidRuntime(18583): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class imageview
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-09 12:37:20.660: E/AndroidRuntime(18583): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.app.Activity.setContentView(Activity.java:1897)
06-09 12:37:20.660: E/AndroidRuntime(18583): at com.regoreminder.RegoReminderActivity.onCreate(RegoReminderActivity.java:13)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.app.Activity.performCreate(Activity.java:4543)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2158)
06-09 12:37:20.660: E/AndroidRuntime(18583): ... 11 more
06-09 12:37:20.660: E/AndroidRuntime(18583): Caused by: java.lang.ClassNotFoundException: android.view.imageview
06-09 12:37:20.660: E/AndroidRuntime(18583): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-09 12:37:20.660: E/AndroidRuntime(18583): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-09 12:37:20.660: E/AndroidRuntime(18583): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:636)
06-09 12:37:20.660: E/AndroidRuntime(18583): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
06-09 12:37:20.660: E/AndroidRuntime(18583): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
06-09 12:37:20.660: E/AndroidRuntime(18583): ... 21 more
JAVA包com.regoreminder;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class RegoReminderActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread logoTimer = new Thread(){
public void run(){
try{
int logoTimer = 0;
while(logoTimer <5000) {
sleep (100);
logoTimer = logoTimer +100;
}
startActivity(new Intent("com.regoreminder.CLEARSCREEN"));
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
finish();
}
}
};
logoTimer.start();
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
}
显现
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.regoreminder"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/icon"
android:label="@string/app_name" >
<activity
android:name=".RegoReminderActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Title"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.regoreminder.CLEARSCREEN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
主要的
<?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:orientation="vertical"
android:background="@drawable/background"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Continue"
android:gravity="center"/>
</LinearLayout>
溅
<?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:orientation="vertical">
<imageview
android:src="@drawable/titlebackground"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
如果有人可以就我做错了什么提供一些帮助,那就太棒了!我一直在关注一个教程,所以我不确定出了什么问题。也在网上寻找答案,但每个人的应用程序都不同。