我只是想从一个窗口切换到下一个窗口,但我不断收到错误消息。我搜索了谷歌,但无法弄清楚我哪里出错了。我希望有人能告诉我发生了什么事。这是错误日志。我得到了一个 classnotfound 但不明白为什么。它在我的清单中。
05-30 23:52:51.129: W/System.err(593): java.lang.ClassNotFoundException: com.jmedia.hvacanalizer.NEWCUSTOMER
05-30 23:52:51.149: W/System.err(593): at java.lang.Class.classForName(Native >Method)
05-30 23:52:51.149: W/System.err(593): at java.lang.Class.forName(Class.java:227)
05-30 23:52:51.149: W/System.err(593): at java.lang.Class.forName(Class.java:174)
05-30 23:52:51.149: W/System.err(593): at com.jmedia.hvacanalizer.HVACAnalizerActivity$1.onClick(HVACAnalizerActivity.java:30)
05-30 23:52:51.169: W/System.err(593): at android.view.View.performClick(View.java:3110)
05-30 23:52:51.169: W/System.err(593): at android.view.View$PerformClick.run(View.java:11934)
05-30 23:52:51.169: W/System.err(593): at android.os.Handler.handleCallback(Handler.java:587)
05-30 23:52:51.179: W/System.err(593): at android.os.Handler.dispatchMessage(Handler.java:92)
05-30 23:52:51.179: W/System.err(593): at android.os.Looper.loop(Looper.java:132)
05-30 23:52:51.190: W/System.err(593): at android.app.ActivityThread.main(ActivityThread.java:4123)
05-30 23:52:51.190: W/System.err(593): at java.lang.reflect.Method.invokeNative(Native Method)
05-30 23:52:51.190: W/System.err(593): at java.lang.reflect.Method.invoke(Method.java:491)
05-30 23:52:51.190: W/System.err(593): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-30 23:52:51.199: W/System.err(593): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-30 23:52:51.199: W/System.err(593): at dalvik.system.NativeStart.main(Native Method)
05-30 23:52:51.199: W/System.err(593): Caused by: java.lang.NoClassDefFoundError: com.jmedia.hvacanalizer.NEWCUSTOMER
05-30 23:52:51.212: W/System.err(593): ... 15 more
05-30 23:52:51.219: W/System.err(593): Caused by: java.lang.ClassNotFoundException: com.jmedia.hvacanalizer.NEWCUSTOMER in loader dalvik.system.PathClassLoader[/data/app/com.jmedia.hvacanalizer-2.apk]
05-30 23:52:51.234: W/System.err(593): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:251)
05-30 23:52:51.234: W/System.err(593): at java.lang.ClassLoader.loadClass(ClassLoader.java:540)
05-30 23:52:51.239: W/System.err(593): at java.lang.ClassLoader.loadClass(ClassLoader.java:500)
05-30 23:52:51.239: W/System.err(593): ... 15 more
这是我清单中的代码...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jmedia.hvacanalizer"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="13" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".HVACAnalizerActivity"
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=".newcustomer"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.jmedia.hvacanalizer.NEWCUSTOMER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
这是我班上的代码...
public class HVACAnalizerActivity extends Activity {
Button bNew, bLookUp;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initialize();
}
public void initialize() {
bNew = (Button) findViewById(R.id.bNewCustomer);
bLookUp = (Button) findViewById(R.id.bLUCustomer);
bNew.setOnClickListener(new View.OnClickListener() {
//@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
try {
Class<?> newCustomerClass = Class.forName("com.jmedia.hvacanalizer.NEWCUSTOMER");
Intent newCustomerIntent = new Intent(
HVACAnalizerActivity.this, newCustomerClass);
startActivity(newCustomerIntent);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
bLookUp.setOnClickListener(new View.OnClickListener() {
//@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
// Class newCustomerClass = null;
}
});
}
如果有人可以在这里帮助我,那就太好了。这是我第一次尝试为 android 编写代码,我已经快要拔掉头发了。