这是我的课程,调试它的true时进度条没有显示,并且在视图中仍然不可见
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = DataBindingUtil.inflate(
inflater,
R.layout.fragment_abc,
container,
false
)
binding.lifecycleOwner = this
// Inflate the layout for this fragment
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel = ViewModelProvider(
this,
InventoryLocationItemsViewModelFactory.getInstance(activity!!.application)
).get(InventoryLocationItemsViewModel::class.java)
binding.viewModel = viewModel
setupObservers()
makeAPICall()
}
private fun setupObservers() {
viewModel.isProductExists.observe(viewLifecycleOwner, Observer {
deleteInventoryProduct(it)
})
viewmodel是
class InventoryLocationItemsViewModel(
val context: Application
) : AndroidViewModel(context) {
val dataLoading = ObservableBoolean(false)
fun makeAPICall() {
dataLoading.set(true)
}
}