私はクイズを開発しています.javaクラスで、startactivityを使用せずに次のボタンをクリックした後に別のクラス(質問)を意図したいのですが、別のメソッドを使用して別のアクティビティを呼び出して別のアクティビティを渡すことは可能ですか? みんな助けてください..どうもありがとう!私の質問が明確であることを願っています..私はあなたの助けに本当に感謝しています!
Question1.java
public class Question1 extends Activity implements OnClickListener
{
int Scorecount = 0;
//private RadioGroup rgp;
private RadioButton rb1;
private RadioButton rb2;
private RadioButton rb3;
private Button b1;
//private TextView t1;
int currentQuestion = 0;
Toast t;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.startquiz);
Scorecount = getIntent().getIntExtra("score",0);
rb1=(RadioButton)findViewById(R.id.option1);
rb2=(RadioButton)findViewById(R.id.option2);
rb3=(RadioButton)findViewById(R.id.option3);
b1=(Button)findViewById(R.id.selected);
b1.setOnClickListener(this);
//rgp=(RadioGroup)findViewById(R.id.QueGroup1);
//t1=(TextView)findViewById(R.id.txtdisplayanswer);
}
@Override
public void onClick(View v) {
if(v == b1)
{
if(rb1.isChecked() || rb2.isChecked() || rb3.isChecked())
{
if(rb1.isChecked())
{
Scorecount++;
Toast.makeText(getApplicationContext(),"Your answer is correct!",
Toast.LENGTH_LONG).show();
/*LinearLayout layout = (LinearLayout) t.getView();
layout.setGravity(Gravity.CENTER);
layout.setBackgroundResource(R.drawable.toastgreen);
//t1.setText("Your answer is correct!" +rb1.getText());*/
}
/*
if(rb2.isChecked() == true)
//t1.setText("Your wrong, the correct answer is: "+rb1.getText());
if(rb3.isChecked() == true)
//t1.setText("Your wrong, the correct answer is: "+rb1.getText());*/
else {
// do nothing
Toast.makeText(getApplicationContext(),"Your answer is wrong! The correct answers is: " + rb1.getText(),
Toast.LENGTH_LONG).show();
/*LinearLayout layout = (LinearLayout) t.getView();
layout.setGravity(Gravity.CENTER);
layout.setBackgroundResource(R.drawable.toastred);*/
}
//Intent i = new Intent(this,Question2.class);
Intent i= getIntent();
i.putExtra("score", Scorecount);
startActivity(i);
finish();
}
}
}