Bindung anzeigen
buildFeatures {
viewBinding true
}
Bad Barracuda
buildFeatures {
viewBinding true
}
// Android Studio 4.0
android {
buildFeatures {
viewBinding = true
}
}
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();
//here data must be an instance of the class MarsDataProvider
binding.setMarsdata(data);
return view;
}
private ResultProfileBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ResultProfileBinding.inflate(getLayoutInflater());
View view = binding.getRoot();
setContentView(view);
}
buildFeatures {
viewBinding true
}
android{
...
//for android gradle plugin 3.6 or lower
viewBinding{
enabled true
}
}