Created
December 16, 2020 15:49
-
-
Save topherPedersen/f19ee2dc7f1c721053217999507801bf to your computer and use it in GitHub Desktop.
Android Button OnClickListener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package blog.topherpedersen.uselesscameraapp; | |
import androidx.appcompat.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.Toast; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Button myButton = findViewById(R.id.my_button); | |
myButton.setOnClickListener(new View.OnClickListener() { | |
public void onClick(View v) { | |
Toast.makeText(getApplicationContext(), "Button Clicked!", Toast.LENGTH_LONG).show(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment