今天把dialogfragment也搭配上bindnig然後试着把dialog的动作移到dialogviewmodel之中
class FragmentDialog: DialogFragment() {
private val viewModel: DialogViewModel<MainDialogResult> by activityViewModels()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val binding = DialogfragmentBinding.inflate(inflater,container,false)
binding.login.setOnClickListener {
val message = "ok"
viewModel.result.postValue(MainDialogResult.Ok(message))
dismiss()
}
binding.cancel.setOnClickListener {
viewModel.result.postValue(MainDialogResult.Cancel)
dismiss()
}
binding.progressBar.visibility = View.VISIBLE
binding.progressBar2.max = 100
Thread{
for (i in 0..100){
binding.progressBar2.progress = i
//Thread.sleep(500)
SystemClock.sleep(500)
}
}.start()
binding.progressBar2.progress = 0
return binding.root
}
}
这边是还没移过去的样子,虽然目前架构还不完整,但是使用databinding之後画面乾净很多,dialog的viewmodel还在研究当中
heap sort的原理是采用max heap这种资料结构来做排序,max heap是一种bina...
作为物理模拟开场的第一进程,当然就要来讲一下最经典的物理模拟案例:『弹跳球』~ 其实很多国外的Can...
前篇回顾 sed - 简介 读取编辑文字档的好工具 sed - 2 Pattern sed - 3 ...
今天要开始实作登入页面,首先我们先新增一个login元件 ng generate component...
回圈有两种语法可以使用,分别是while与for回圈,今天这篇会先来讲到while回圈的部分。 基本...