how to use view binding in fragment code example
Example 1: binding fragment android
example:
public View onCreateView(LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
MartianDataBinding binding = DataBindingUtil.inflate(
inflater, R.layout.martian_data, container, false);
View view = binding.getRoot();
binding.setMarsdata(data);
return view;
}
Example 2: kotlin binding views to activity
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-android-extensions'
}
<Button
android:id="@+id/btn_finish"
(...)
btn_finish.setOnClickListener {
}