Data binding在Activity中使用:
DataBindingUtil.setContentView(this, R.layout.activity_home);
Data binding在Fragment中使用:
DataBindingUtil.inflate(inflater, R.layout.homepage_fragment, container, false);
Data binding在activity中或者fragment加载其他布局怎么办呢?比如 popupwindow之类的
其实也挺简单的:
ItemMapInfoBinding infoBinding = ItemMapInfoBinding.inflate(getLayoutInflater());View popupView = infoBinding.getRoot();PopupWindow mPopupWindow = new PopupWindow(mContext);mPopupWindow.setContentView(popupView);关于Data binding其他的 遇到在补充吧。
时间: 2024-10-02 21:20:08