我想從登錄活動切換...我擁有所有的表單,但是當我點擊按鈕時,它就會關閉。開關活動出錯
這是我的代碼。
頭等艙
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final EditText pass = (EditText)findViewById(R.id.editText1);
final Intent myIntent = new Intent(getApplicationContext(), Menu.class);
String mydate = java.text.DateFormat.getDateInstance().format(Calendar.getInstance().getTime());
TextView fecha = (TextView)findViewById(R.id.textView2);
fecha.setText(mydate);
Button next = (Button) findViewById(R.id. button1);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if("12345".equals(pass.getText().toString())) {
//Toast.makeText(getApplicationContext(), "Clave Correcta", Toast.LENGTH_SHORT).show();
startActivity(myIntent);
}
else {
Toast.makeText(getApplicationContext(), "Clave Incorrecta", Toast.LENGTH_SHORT).show();
}
}
});
}
第二類人。
public class Menu extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
}
}
登錄貓:
12-21 17:04:53.710: E/Trace(2389): error opening trace file: No such file or directory (2)
12-21 17:04:57.680: E/AndroidRuntime(2389): FATAL EXCEPTION: main
12-21 17:04:57.680: E/AndroidRuntime(2389): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.pizzasjaps/android.view.Menu}; have you declared this activity in your AndroidManifest.xml?
12-21 17:04:57.680: E/AndroidRuntime(2389): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1541)
12-21 17:04:57.680: E/AndroidRuntime(2389): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
12-21 17:04:57.680: E/AndroidRuntime(2389): at android.app.Activity.startActivityForResult(Activity.java:3351)
12-21 17:04:57.680: E/AndroidRuntime(2389): at android.app.Activity.startActivityForResult(Activity.java:3312)
12-21 17:04:57.680: E/AndroidRuntime(2389): at android.app.Activity.startActivity(Activity.java:3522)
12-21 17:04:57.680: E/AndroidRuntime(2389): at android.app.Activity.startActivity(Activity.java:3490)
12-21 17:04:57.680: E/AndroidRuntime(2389): at com.example.pizzasjaps.MainActivity$1.onClick(MainActivity.java:39)
12-21 17:04:57.680: E/AndroidRuntime(2389): at android.view.View.performClick(View.java:4084)
12-21 17:04:57.680: E/AndroidRuntime(2389): at android.view.View$PerformClick.run(View.java:16966)
12-21 17:04:57.680: E/AndroidRuntime(2389): at android.os.Handler.handleCallback(Handler.java:615)
12-21 17:04:57.680: E/AndroidRuntime(2389): at android.os.Handler.dispatchMessage(Handler.java:92)
12-21 17:04:57.680: E/AndroidRuntime(2389): at android.os.Looper.loop(Looper.java:137)
12-21 17:04:57.680: E/AndroidRuntime(2389): at android.app.ActivityThread.main(ActivityThread.java:4906)
12-21 17:04:57.680: E/AndroidRuntime(2389): at java.lang.reflect.Method.invokeNative(Native Method)
12-21 17:04:57.680: E/AndroidRuntime(2389): at java.lang.reflect.Method.invoke(Method.java:511)
12-21 17:04:57.680: E/AndroidRuntime(2389): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
12-21 17:04:57.680: E/AndroidRuntime(2389): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
12-21 17:04:57.680: E/AndroidRuntime(2389): at dalvik.system.NativeStart.main(Native Method)
LogCat總是有幫助:) – AndroidPenguin