Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataBindingUtil.setContentView - Type parameter T has incompatible upper bounds

Tags:

android

"Android Studio" shows error message "Type parameter T has incompatible upper bounds: ViewDataBinding and ActivityChecklistsBinding.

ActivityChecklistsBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_checklists); 

Before update the ADK it works fine. Is there any ideas what wrong?

like image 433
tse Avatar asked Aug 23 '15 19:08

tse


People also ask

How check data binding is null in Android?

Generated data binding code automatically checks for null values and avoid null pointer exceptions. For example, in the expression @{user.name} , if user is null, user.name is assigned its default value of null . If you reference user. age , where age is of type int , then data binding uses the default value of 0 .


2 Answers

I had the same problem. I tried a couple of things, Clean and Rebuild project.

But, It worked after I choose File -> Invalidate Caches / Restart

like image 109
Hjord Avatar answered Oct 19 '22 01:10

Hjord


The binding activity is automatically generated and takes the name from the layout file, not the activity class.

So if you have an activity named BeautifulActivity and the corresponding layout named sweet_layout.xml, then the generated name will be SweetLayoutBinding and not BeautifulActivityBinding.

Don't make my same mistake by confusing between MainActivity and activity_main.xml 😉

Source Android Developers

like image 26
Guido Lodetti Avatar answered Oct 19 '22 02:10

Guido Lodetti