I have an xml page with 3 buttons on all leading to similar xml files. However, the second and third buttons only respond if the first has been pressed (and then you go back a page and press another). If I reverse the order of the buttons in the java file, which ever button is listed first is the one that has to be used befor the others.
Here is my java for the buttons:
________________________________________________________
package converter.units.kitchen;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Menu2 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.convertmenu);
Button start = (Button) findViewById(R.id.buttonLitres);
start.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("android.intent.action.CONVERTLITRES"));
Button start = (Button) findViewById(R.id.buttonGrams);
start.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("android.intent.action.CONVERTGRAMS"));
Button start = (Button) findViewById(R.id.buttonOunces);
start.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("android.intent.action.CONVERTOUNCES"));
}
});
}
});
}
});
} }
_____________________________
Any help would be greatly appreciated, the rest of the app has no errors and functions correctly. Thank you very much
Here is my java for the buttons:
________________________________________________________
package converter.units.kitchen;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Menu2 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.convertmenu);
Button start = (Button) findViewById(R.id.buttonLitres);
start.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("android.intent.action.CONVERTLITRES"));
Button start = (Button) findViewById(R.id.buttonGrams);
start.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("android.intent.action.CONVERTGRAMS"));
Button start = (Button) findViewById(R.id.buttonOunces);
start.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("android.intent.action.CONVERTOUNCES"));
}
});
}
});
}
});
} }
_____________________________
Any help would be greatly appreciated, the rest of the app has no errors and functions correctly. Thank you very much