Skip to content

Instantly share code, notes, and snippets.

@killvetrov
killvetrov / BaseViewBindingFragment.java
Last active November 15, 2022 12:58
Android View Binding: base class to reduce boilerplate in Java
public abstract class BaseViewBindingFragment extends Fragment {
private Field bindingField;
private Method inflate;
{
try {
for (Field declaredField : this.getClass().getDeclaredFields()) {
if (ViewBinding.class.isAssignableFrom(declaredField.getType())) {
bindingField = declaredField;