How can I implement the switch in Google translator or in the screenshot below?
I did it, but the texts are switched from the second click on the button.
public class MainActivity extends AppCompatActivity { private int sw; TextView txtLeft; TextView txtRight; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); txtLeft = findViewById(R.id.txtLeft); txtRight = findViewById(R.id.txtRight); ImageButton btnRef = findViewById(R.id.btnRef); sw = 0; txtLeft.setText("Π ΡΡΡΠΊΠΈΠΉ"); txtRight.setText("ΠΠ½Π³Π»ΠΈΠΉΡΠΊΠΈΠΉ"); btnRef.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switch (sw){ case 0: txtLeft.setText("Π ΡΡΡΠΊΠΈΠΉ"); txtRight.setText("ΠΠ½Π³Π»ΠΈΠΉΡΠΊΠΈΠΉ"); sw = 1; break; case 1: txtLeft.setText("ΠΠ½Π³Π»ΠΈΠΉΡΠΊΠΈΠΉ"); txtRight.setText("Π ΡΡΡΠΊΠΈΠΉ"); sw = 0; break; } } }); } }