I want a checkbox to be checked before they can continue to go to the next page (XML). It is working seperate but not together. In the sence that if I push the play button without a checked checkbox, it should only show the toast. This is what I got.
XML checkbox has itemClicked aas onClick method Button has startNewActivity as onClick method.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void itemClicked (View v) {
final Button play =(Button)findViewById(R.id.playButton);
CheckBox Approved = (CheckBox) findViewById(R.id.Approved);
Approved.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (((CheckBox) v).isChecked()) {
play.setEnabled(true);
} else {
Toast.makeText(MainActivity.this, "Please Approve!", Toast.LENGTH_LONG).show();
}
}
});
}
public void startNewActivity (View view){
final EditText edit = (EditText) findViewById(R.id.editText);
String Name = (String) edit.getText().toString();
Intent intent = new Intent (this, GameSetUp.class);
intent.putExtra("name", Name);
itemClicked(view);
startActivity(intent);
}
}
Please can you tell what I am doing wrong.
Gr. Jeroen
Aucun commentaire:
Enregistrer un commentaire