@Override
public void onClick(View v) {
if(v.getId() == R.id.yourbuttonid) {
btn.setText("X");
}else if(v.getId() == R.id.yourbuttonid2){
btn2.setText("X");
}
}
package com.example.f3;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onClick(View view){
Button btn = (Button)findViewById(R.id.button);
btn.setText("HELLO WORLD");
}
}