AI智能
改变未来

android mvvm databinding在dialog中的使用


自定义dialog

/*** Created by zhaoxiaoyu on 2019/10/31 0031.*/public class CardDialog extends Dialog{private DialogCardBinding cardBinding;private CardViewModel cardViewModel;private int num;public CardDialog(@NonNull Context context,int resid,int num) {super(context,resid);this.num=num;}@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);cardBinding= DataBindingUtil.inflate(LayoutInflater.from(getContext()),R.layout.dialog_card, null, false);cardViewModel=new CardViewModel(cardBinding,this,num);setContentView(cardBinding.getRoot());}@Overridepublic void dismiss() {super.dismiss();cardViewModel.dismiss();}}
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » android mvvm databinding在dialog中的使用