-
-
Save codeforfun-jp/cde87e4fbe65ccd192688bbec81cbe0b to your computer and use it in GitHub Desktop.
How to Use View Binding with Java & Kotlin - 5
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
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