嘿伙计们,我正在尝试创建一个测验,但我的意图有问题,在用户单击按钮后,它会自动意图进行另一个活动.. 我该怎么做?
请帮助大家...提前谢谢..
这是代码:
if(btn1.isClickable())
{
img1.setVisibility(View.VISIBLE);
img1.setImageResource(R.drawable.check);
img2.setVisibility(View.INVISIBLE);
img2.setImageResource(R.drawable.wrong);
img3.setVisibility(View.INVISIBLE);
img3.setImageResource(R.drawable.wrong);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Scorecount++;
Intent i = getIntent();
startActivity(i);
Scorecount = i.getIntExtra("score",0);
}
});
}
else if (btn2.isClickable())
{
img2.setVisibility(View.VISIBLE);
img2.setImageResource(R.drawable.wrong);
img1.setVisibility(View.INVISIBLE);
img1.setImageResource(R.drawable.wrong);
img3.setVisibility(View.INVISIBLE);
img3.setImageResource(R.drawable.wrong);
}
else if (btn3.isClickable())
{
img3.setVisibility(View.VISIBLE);
img3.setImageResource(R.drawable.wrong);
img2.setVisibility(View.INVISIBLE);
img2.setImageResource(R.drawable.wrong);
img1.setVisibility(View.INVISIBLE);
img1.setImageResource(R.drawable.wrong);
}
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = getIntent();
startActivity(i);
Scorecount = i.getIntExtra("score",0);
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i = getIntent();
startActivity(i);
}
});
btn3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i = getIntent();
startActivity(i);
}
});
}
}