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 ExampleFragment extends Fragment { | |
private FragmentExampleBinding binding; | |
@Nullable | |
@Override | |
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, @Nullable Bundle savedInstanceState) { | |
return ViewBindingDelegate.inflate( | |
FragmentExampleBinding::inflate, b -> binding = b, | |
inflater, container, getViewLifecycleOwner()); |
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 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; |