java使用片段中的数据绑定和相关活动的不同包
我有一个片段的集合,我在许多应用程序中使用,所以它们都在foo中。酒吧组件和standolone项目,其中一个在布局中使用数据绑定,当我在不同包中的活动中使用片段时会出现问题。酒吧应用程序
Unable to start activity ComponentInfo{foo.bar.app/foo.bar.app.Activity}: java.lang.ClassCastException: foo.bar.app.databinding.FragmentFooBindingImpl cannot be cast to foo.bar.components.databinding.FragmentFooBinding
我在片段中进行绑定,如下所示:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
FragmentFooBinding binding = DataBindingUtil.inflate(
inflater, R.layout.fragment_foo, container, false);
binding.setItem(Item);
return binding.getRoot();
}
有什么建议吗
共 (0) 个答案