Im working on a game with buttons in android. I am translating my VB2010 game on java but i dont know what is the equivalent of VB coding to java such as "Button1.TEXT = Button2.TEXT" and...
Sub CheckButton(ByRef Butt1 As Button, ByRef Butt2 As Button)
If Butt2.Text = "" Then
Butt2.Text = Butt1.Text
Butt1.Text = ""
End If
End Sub
Sub CheckSolved()
If Form1.Button1.Text = "1" And Form1.Button2.Text = "2" And Form1.Button3.Text = "3" And
Form1.Button4.Text = "4" And Form1.Button5.Text = "5" And Form1.Button6.Text = "6" And
Form1.Button7.Text = "7" And Form1.Button8.Text = "8" And Form1.Button9.Text = "9" And
Form1.Button10.Text = "10" And Form1.Button11.Text = "11" And Form1.Button12.Text = "12" And
Form1.Button13.Text = "13" And Form1.Button14.Text = "14" And Form1.Button15.Text = "15" Then
MsgBox("Wow, You did it in " & Form1.Count & " Clicks ", vbInformation, "Shuffle")
End If
Form1.Count = Form1.Count + 1
Form1.Text = "Shuffle : " & Form1.Count & " Clicks"
End Sub
...to Java. In short, I am translating my VB2010 project into an android app.
Here's my codes in eclipse and i cant make it work.
import android.widget.Button;
import android.widget.TextView;
public class Activ2 extends Activity implements OnClickListener {
Button btn1, btn2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activ2);
btn1 = (Button) findViewById(R.id.btn1);
btn2 = (Button) findViewById(R.id.btn2);
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CheckButton(btn1, btn2);
}
});
public static void CheckButton(Button Butt1, Button Butt2)
{
if (Butt2.equals(""))
{
Butt2.setText(Butt1.getText());
Butt1.setText("");
}
}
}
i have an error in these lines:
CheckButton(btn1, btn2);
Error: The method CheckButton(Button, Button) is undefined for the type new View.OnClickListener(){}
AND
public static void CheckButton(Button Butt1, Button Butt2)
Error: Multiple markers at this line
- Syntax error on token ")", ; expected
- void is an invalid type for the variable
CheckButton
- Syntax error on token "(", ; expected
- Syntax error on token ",", ; expected
- btn cannot be resolved to a type
- Syntax error on token ",", ; expected