;//设置背景,并没有什么用Р helpTimes = 0;//重新开始后,使用帮助的次数清零Р }Р});Р帮助功能的实现代码:Рaskhelp.setOnClickListener(new OnClickListener() {//点击使用帮助,实现交换任意两个数字的功能Р @OverrideР public void onClick(View arg0) {Р if (helpTimes == 0) {//为0,表示未使用过帮助Р LayoutInflater inflater = LayoutInflaterР .from(ShiftGame.this);Р final View askHelpView = inflater.inflate(R.layout.askhelp,Р null);Р new AlertDialog.Builder(ShiftGame.this)Р .setTitle("交换数字")Р .setView(askHelpView)Р .setPositiveButton("交换",Р new DialogInterface.OnClickListener() {Р @OverrideР public void onClick(Р DialogInterface dialog,Р int which) {//获得输入的两个数字Р int num1 = IntegerР .valueOf(((EditText) (askHelpViewР .findViewById(R.id.helpnum1)))Р .getText()Р .toString());Р int num2 = IntegerР .valueOf(((EditText) (askHelpViewР .findViewById(R.id.helpnum2)))Р .getText()