btn1 = (Button) findViewById(R.id.btn1); btn2 = (Button) findViewById(R.id.btn2); btn3 = (Button) findViewById(R.id.btn3); btn4 = (Button) findViewById(R.id.btn4); btn5 = (Button) findViewById(R.id.btn5); btn6 = (Button) findViewById(R.id.btn6); btn1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CheckButton(btn1, btn2); CheckButton(btn1, btn4); } }); btn2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CheckButton(btn2, btn1); CheckButton(btn2, btn3); CheckButton(btn2, btn5); } }); .........and so on. } private void CheckButton(final Button btn1, final Button btn2) { if (btn2.getText().equals("")) { btn2.setText(btn1.getText().toString()); btn1.setText(""); } }
ibtn1 = (ImageButton) findViewById(R.id.ibtn1); ibtn2 = (ImageButton) findViewById(R.id.ibtn2); ibtn1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CheckiButton(ibtn1, ibtn2); } }); ibtn2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CheckiButton(ibtn2, ibtn1); } }); private void CheckiButton(final ImageButton ibtn1, final ImageButton ibtn2) { if (ibtn2.getBackground().equals("")) { ibtn2.setBackground(ibtn1.getBackground()); ibtn1.setBackgroundResource(""); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)