YogenGhodke
9/3/2019 - 5:41 PM

Button

import android.widget.*;

// In onCreate
final Button x = findViewById(R.id.button);      // Link object to existing button

// On Clicking the Button, Activity to be performed...
myButton.setOnClickListener
(
    new View.OnClickListener() 
    {
        @Override
            public void onClick(View view) 
            {
                // ...Goes Here
                showText.setText("This button was pressed.");
            }
    }
);


OR

// Using Interface

o1.setOnClickListener(this);        // Error occurs. Click Lightbulb and second option and click OK


OR
 
// In Activity_Main.xml , under button add
 
android:onClick="abc"
 
// in Java File, add outside OnCreate()
 
public void abc(View s)
    {
 
    }

//Remove Button Shadow

style="?android:attr/borderlessButtonStyle"