DataBindingUtil.setContentView - Type parameter T has incompatible upper bounds

前端 未结 9 763
逝去的感伤
逝去的感伤 2021-02-02 06:54

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

ActivityChecklistsBindin         


        
9条回答
  •  囚心锁ツ
    2021-02-02 07:06

    When I first meet this error, I create a layout named a.xml, and then I Create a Activity like this

    public class ABinding extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            ABinding binding = DataBindingUtil.setContentView(this, R.layout.a);
        }
    
    }
    

    and this error occurs. Finally I found out Class ABinding was automatically generated in /build, so activity with name ABinding will overwrite the auto generated class

    so I rename the Activity and the error disappear

提交回复
热议问题