Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

change button text when clicked android studio

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

Android Change Text Of Button On Click

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

PREVIOUS NEXT
Code Example
Java :: java printf double 2 decimal places 
Java :: spring boot logged in user 
Java :: text.settextcolor android 
Java :: java output 
Java :: jackson localdate 
Java :: java string to path 
Java :: spigot respawn player location 
Java :: how to create immutable list java 
Java :: java code to print hello world 
Java :: java alert box 
Java :: unparseable date error in java 
Java :: create method setsupportactionbar 
Java :: java get ip address 
Java :: JAVA_HOME not found in your environment. 
Java :: android vibrate 
Java :: get random word from list java 
Java :: java create image 
Java :: event api spigot 
Java :: how to read a json file in java 
Java :: how to find the average in an arraylist 
Java :: how to add elements to an array in java dynamically 
Java :: imageio class java 
Java :: how to get width android 
Java :: circular textview android 
Java :: convert string to character array 
Java :: counting nodes in binary search tree 
Java :: get time android 
Java :: list of lists java 
Java :: How to create a popup window (PopupWindow) in Android 
Java :: kjk;ok 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =