Reputation: 123
I'm adding in my gradle
buildFeatures {
viewBinding true
}
public class MainActivity3 extends AppCompatActivity {
ActivityMain3Binding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMain3Binding.inflate(getLayoutInflater());
binding=DataBindingUtil // don't found
View view = binding.getRoot();
setContentView(view);
binding.EdName.setText("test text");
}
I need help or good and new tutorial to understand dataBinding
Upvotes: 5
Views: 6294
Reputation: 123
You also need to enable data binding in build.gradle
buildFeatures { dataBinding true viewBinding true }
Upvotes: 1
Reputation: 149
1-In your app’s build.gradle set data binding as usual
2-Add the compiler dependency
3- Then apply the plugin at the top of the file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
buildFeatures {
dataBinding true
}
}
dependencies {
kapt "com.android.databinding:compiler:3.0.1"
}
Upvotes: 1
Reputation: 20714
You also need to enable data binding in your app-level build.gradle
:
android {
...
buildFeatures {
dataBinding true
viewBinding true
}
}
Upvotes: 19