-1

我得到应用程序已停止。该项目将场景从 MainAplication 更改为 JobList,但是,将 Job List 更改为 ExerciseList,我正在接受这些“不幸的是应用程序已停止”。在模拟器上。这是我的课程。我也在 logcat 上得到了 FATAL EXCEPTİN。

应用程序主程序.java

    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;

    public class ApplicationMain extends Activity {
/** Called when the activity is first created. */
EditText nameEditCtrl;
Button btnCtlr;
String name;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    nameEditCtrl = (EditText) findViewById(R.id.editText1);
    btnCtlr = (Button) findViewById(R.id.button1);
    btnCtlr.setOnClickListener(new ButtonClickHandler());
}

public class ButtonClickHandler implements View.OnClickListener {
    public void onClick(View view) {
        if (nameEditCtrl != null && nameEditCtrl.getText().length() != 0) {
            name = nameEditCtrl.getText().toString();
        } else {
            name = "Guest";
        }
        Intent intObj = new Intent(ApplicationMain.this,
                JobList.class);
        intObj.putExtra("USERNAME", name);
        startActivity(intObj);
    }
}
 }

作业列表.Java

    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.ImageButton;
    import android.widget.TextView;

    public class JobList extends Activity {
TextView greetMsg;
ImageButton ib;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.joblist);
    greetMsg = (TextView) findViewById(R.id.textView1);
    Intent intename = getIntent();
    String uname = (String) intename.getSerializableExtra("USERNAME");
    greetMsg.setText("Welcome " + uname);



    ib = (ImageButton) findViewById(R.id.imageButton1);
    ib.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intObj = new Intent(JobList.this,ExerciseList.class);
            startActivity(intObj);
        }
    });





    }

}

练习列表.Java

      import android.app.Activity;
      import android.content.Intent;
      import android.os.Bundle;
      import android.view.View;
      import android.widget.Button;
      import android.widget.EditText;
      import android.widget.ImageButton;
      import android.widget.TextView;


     public class ExerciseList extends Activity {

ImageButton iz;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.exerciselist);

    iz = (ImageButton) findViewById(R.id.imageButton2);
        iz.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            Intent intObj = new Intent(ExerciseList.this,
                    ApplicationMain.class);
            //intObj.putExtra("USERNAME", name);
            startActivity(intObj);
        }
    });


}
 }

AndroidManifest.xml

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.prgguru.android"
android:versionCode="1"
android:versionName="1.0" >


<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".ApplicationMain"
        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=".JobList"
        android:label="@string/app_name" >
    </activity>
</application>

     </manifest>
4

1 回答 1

5

您忘记在 manifest.xml 中注册您的活动

<activity
        android:name=".ExerciseList"
        android:label="@string/app_name" >
    </activity>
于 2013-03-27T09:04:24.850 回答