I am getting Application has stopped. The project changes scene to MainAplication to JobList but, Job List to ExerciseList, ı am gettin these "Unfortunately application has stopped." on emulator.Here is my classes. I am also gettin FATAL EXCEPTİN on logcat.
ApplicationMain.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);
}
}
}
JobList.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);
}
});
}
}
ExerciseList.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
package="com.prgguru.android"
android:versionCode="1"
android:versionName="1.0" >
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
android:name=".ApplicationMain"
android:label="@string/app_name" >
android:name=".JobList"
android:label="@string/app_name" >
No comments:
Post a Comment