Android Change Text Of Button On Click

[Solved] Android Change Text Of Button On Click | Swift - Code Explorer | yomemimo.com
Question : change button text when clicked android studio

Answered by : uptight-unicorn-5aol0hh2pqjp

@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"); }
}

Source : https://stackoverflow.com/questions/40270234/android-studio-how-to-change-a-buttons-text-onclick | Last Update : Thu, 14 Oct 21

Question : Android Change Text Of Button On Click

Answered by : eric-tam

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"); }
}

Source : | Last Update : Sat, 03 Sep 22

Answers related to android change text of button on click

Code Explorer Popular Question For Swift