1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| public class MainActivity extends Activity {
Button button1;
Button button2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String test = "t";
Intent intent = new Intent(MainActivity.this, NextActivity.class);
intent.putExtra("code", test);
startActivity(intent);
}
});
button2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View t) {
// TODO Auto-generated method stub
String test = "to";
Intent intent = new Intent(MainActivity.this, NextActivity.class);
intent.putExtra("code", test);
startActivity(intent);
}
});
}
} |