我对编程很陌生,刚刚遇到了一个阻碍我的简单路障。我试图让我的主要活动中的一个按钮调用另一个活动。我已经研究过,但到目前为止我还没有找到可以工作的东西(可能非常简单和愚蠢)。任何帮助,将不胜感激。我已经包含了我的主要活动的代码。谢谢
package com.example.valentinetimer;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class CardFront extends Activity implements OnClickListener {
private static final String TAG = null;
Button openButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cardfrontxml);
Log.d(TAG, "onCreate");
//Button
openButton = (Button) findViewById(R.id.openButton);
openButton.setOnClickListener(this);
this.setContentView(R.layout.cardfrontxml);
this.openButton = (Button)this.findViewById(R.id.openButton);
this.openButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
Log.d(TAG, "Click Event");
Intent intent = new Intent (null, CardContent.class);
startActivity (intent);
}
});
//End Button
}
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
}
}
日志猫:
02-08 10:18:51.927: E/AndroidRuntime(2494): FATAL EXCEPTION: main
02-08 10:18:51.927: E/AndroidRuntime(2494): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.valentinetimer/com.example.valentinetimer.CardContent}; have you declared this activity in your AndroidManifest.xml?
02-08 10:18:51.927: E/AndroidRuntime(2494): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1504)
02-08 10:18:51.927: E/AndroidRuntime(2494): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1382)
02-08 10:18:51.927: E/AndroidRuntime(2494): at android.app.Activity.startActivityForResult(Activity.java:3095)
02-08 10:18:51.927: E/AndroidRuntime(2494): at android.app.Activity.startActivity(Activity.java:3201)
02-08 10:18:51.927: E/AndroidRuntime(2494): at com.example.valentinetimer.CardFront$1.onClick(CardFront.java:42)
02-08 10:18:51.927: E/AndroidRuntime(2494): at android.view.View.performClick(View.java:3110)
02-08 10:18:51.927: E/AndroidRuntime(2494): at android.view.View$PerformClick.run(View.java:11928)
02-08 10:18:51.927: E/AndroidRuntime(2494): at android.os.Handler.handleCallback(Handler.java:587)
02-08 10:18:51.927: E/AndroidRuntime(2494): at android.os.Handler.dispatchMessage(Handler.java:92)
02-08 10:18:51.927: E/AndroidRuntime(2494): at android.os.Looper.loop(Looper.java:132)
02-08 10:18:51.927: E/AndroidRuntime(2494): at android.app.ActivityThread.main(ActivityThread.java:4025)
02-08 10:18:51.927: E/AndroidRuntime(2494): at java.lang.reflect.Method.invokeNative(Native Method)
02-08 10:18:51.927: E/AndroidRuntime(2494): at java.lang.reflect.Method.invoke(Method.java:491)
02-08 10:18:51.927: E/AndroidRuntime(2494): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
02-08 10:18:51.927: E/AndroidRuntime(2494): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
02-08 10:18:51.927: E/AndroidRuntime(2494): at dalvik.system.NativeStart.main(Native Method)