请帮助我完成这个项目。这个条件适用于我们的游戏进度。这里的错误是当其中一个if语句是正确的时,如果你输出另一个按钮并正确得到答案,结果就不再添加了......请帮帮我..非常感谢..:DD
try
{
if(questonedone==true)
{
btl1.setBackgroundResource(R.drawable.f1);
btl1.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questtwodone==true)
{
btl2.setBackgroundResource(R.drawable.f5);
btl2.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questthreedone==true)
{
btl3.setBackgroundResource(R.drawable.f9);
btl3.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questfourdone==true)
{
btl4.setBackgroundResource(R.drawable.f13);
btl4.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questfivedone==true)
{
btl5.setBackgroundResource(R.drawable.f2);
btl5.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questsixdone==true)
{
btl6.setBackgroundResource(R.drawable.f6);
btl6.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questsevendone==true)
{
btl7.setBackgroundResource(R.drawable.f10);
btl7.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questeightdone==true)
{
btl8.setBackgroundResource(R.drawable.f14);
btl8.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questninedone==true)
{
btl9.setBackgroundResource(R.drawable.f3);
btl9.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questtendone==true)
{
btl10.setBackgroundResource(R.drawable.f7);
btl10.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questelevendone==true)
{
btl11.setBackgroundResource(R.drawable.f11);
btl11.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questtwelvedone==true)
{
btl12.setBackgroundResource(R.drawable.f15);
btl12.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questthirteendone==true)
{
btl13.setBackgroundResource(R.drawable.f4);
btl13.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questfourteendone==true)
{
btl14.setBackgroundResource(R.drawable.f8);
btl14.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questfifteendone==true)
{
btl15.setBackgroundResource(R.drawable.f12);
btl15.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
if(questsixteendone==true)
{
btl16.setBackgroundResource(R.drawable.f16);
btl16.setEnabled(false);
counter = percent + 6.25 ;
counter2 = percent2 + 1;
}
result.setText(counter + "%");
result2.setText(counter2 + " out of 16");
}
catch(Exception e)
{
}
答案 0 :(得分:0)
将百分比替换为计数器 和%2到counter2。