67.10 Preparing the Main Fragment
The last remaining component to modify is the MainFragment class which needs to configure listeners on the Button views and observers on the live data objects located in the ViewModel class. Before adding this code, some preparation work needs to be performed to add some imports, variables and to obtain references to view ids. We will also need to modify the fragment to make use of view binding. Edit the MainFragment.java file and modify it as follows:
.
.
import com.ebookfrenzy.roomdemo.databinding.MainFragmentBinding;
.
.
public class MainFragment extends Fragment {
private MainViewModel mViewModel;
private MainFragmentBinding binding;
private ProductListAdapter adapter;
.
.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
...