Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created September 7, 2023 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeforfun-jp/cde87e4fbe65ccd192688bbec81cbe0b to your computer and use it in GitHub Desktop.
Save codeforfun-jp/cde87e4fbe65ccd192688bbec81cbe0b to your computer and use it in GitHub Desktop.
How to Use View Binding with Java & Kotlin - 5
public class MainActivity extends AppCompatActivity {
private ActivityMainBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
binding.btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
binding.message.setText("こんにちは");
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment