With that said, I have written a droid app for the company I work for, although I've never worked in java before. All the components/activities work fine, except one thing:
On the main activity, I have 4 buttons to click to 4 other activities. The buttons work, BUT YOU HAVE TO CLICK THE BUTTONS IN ORDER (top to bottom) to get each click to summon the new activities. Once all 4 activities have been clicked (and back button clicked to get back to the main activity), then the buttons work fine in any order.
WHAT THE HECK DID I DO WRONG?? I've searched tutorials, forums, and basically the entire internet, and it appears I'm the only one to ever have this problem. I'm not sure if my java is wrong, but it shows no errors. Here is the java for the main activity below.
PLEASE HELP - I'M GOING TO STAB MYSELF IN THE NECK IF I CAN'T FIGURE THIS OUT! Seriously, it's very frustrating.
package com.acrrestores.droidapp1;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b1 = (Button) findViewById(R.id.buttonMain1);
b1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(Main.this,emergency_response.class));
Button b2 = (Button) findViewById(R.id.buttonMain3);
b2.setOnClickListener(new OnClickListener () {
public void onClick(View v) {
startActivity (new Intent(Main.this, acr_services.class));
Button b3 = (Button) findViewById(R.id.buttonMain2);
b3.setOnClickListener(new OnClickListener () {
public void onClick(View v) {
startActivity (new Intent(Main.this, service_territory.class));
Button b4 = (Button) findViewById(R.id.buttonMain4);
b4.setOnClickListener(new OnClickListener () {
public void onClick(View v) {
startActivity (new Intent(Main.this, acrcontacts.class));
}
});
}
});
}
});
}
});
}}
On the main activity, I have 4 buttons to click to 4 other activities. The buttons work, BUT YOU HAVE TO CLICK THE BUTTONS IN ORDER (top to bottom) to get each click to summon the new activities. Once all 4 activities have been clicked (and back button clicked to get back to the main activity), then the buttons work fine in any order.
WHAT THE HECK DID I DO WRONG?? I've searched tutorials, forums, and basically the entire internet, and it appears I'm the only one to ever have this problem. I'm not sure if my java is wrong, but it shows no errors. Here is the java for the main activity below.
PLEASE HELP - I'M GOING TO STAB MYSELF IN THE NECK IF I CAN'T FIGURE THIS OUT! Seriously, it's very frustrating.
package com.acrrestores.droidapp1;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b1 = (Button) findViewById(R.id.buttonMain1);
b1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(Main.this,emergency_response.class));
Button b2 = (Button) findViewById(R.id.buttonMain3);
b2.setOnClickListener(new OnClickListener () {
public void onClick(View v) {
startActivity (new Intent(Main.this, acr_services.class));
Button b3 = (Button) findViewById(R.id.buttonMain2);
b3.setOnClickListener(new OnClickListener () {
public void onClick(View v) {
startActivity (new Intent(Main.this, service_territory.class));
Button b4 = (Button) findViewById(R.id.buttonMain4);
b4.setOnClickListener(new OnClickListener () {
public void onClick(View v) {
startActivity (new Intent(Main.this, acrcontacts.class));
}
});
}
});
}
});
}
});
}}