Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created Jul 11, 2021
Embed
What would you like to do?
how to set button click event 2-3
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.btn).setOnClickListener(this);
}
@Override
public void onClick(View v) {
Snackbar.make(v, "ボタンが押されました", Snackbar.LENGTH_SHORT).show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment