Slide 29
Slide 29 text
//com.example.android.persistence.ProductFragment
//Java
private ProductFragmentBinding mBinding;
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
mBinding = DataBindingUtil.inflate(inflater, R.layout.product_fragment, container, false);
//...
mBinding.commentList.setAdapter(mCommentAdapter);
return mBinding.getRoot();
}
//Kotlin (Auto)
private var mBinding: ProductFragmentBinding? = null
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
mBinding = DataBindingUtil.inflate(inflater!!, R.layout.product_fragment,
container, false)
//...
mBinding!!.commentList.adapter = mCommentAdapter
return mBinding!!.root
}