lundi 23 février 2015

Android java impliment 2 buttons in 1 page



Hello i finally learned about adding a button to a page and actually making it navigate to another activity "XML Page"... anyway i been trying to add 2 buttons in the same page which navigate each to a different XML's Pages... All i did was copying the first button which worked and then changing the button name and all other things the first button works but the second isn't.. it shows a click but nothing happens after... Back1 Button works.. TMode Button does the trouble.. Eclipse is not showing errors


Here is my code -


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 GameMode extends Activity {



/** Called when the activity is first created.*/
Button btn;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_game_mode);

btn=(Button)findViewById(R.id.Back1);

btn.setOnClickListener(btn2Listener);
}


private OnClickListener btn2Listener=new OnClickListener() {

public void onClick(View v) {


Intent intent2=new Intent(GameMode.this,MainActivity.class);

startActivity(intent2);

}
};
Button btn1;
public void onCreate1(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_game_mode);

btn=(Button)findViewById(R.id.TMode);
btn.setOnClickListener(btn3Listener);
}


private OnClickListener btn3Listener=new OnClickListener() {
public void onClick(View v) {


Intent intent3=new Intent(GameMode.this,CharacterSelect.class);

startActivity(intent3);

}
};


}




Aucun commentaire:

Enregistrer un commentaire