Android AlertDialog inside AsyncTask

前端 未结 4 1744
隐瞒了意图╮
隐瞒了意图╮ 2021-01-01 05:57

I have a listview which have checkboxes. For each checkbox (they are about 3), it has a specific AsyncTask for it.

I never know what checkboxes use

4条回答
  •  梦谈多话
    2021-01-01 06:31

    you can access ui by this method inside the function doInBackground... :

    getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (!dialog.isShowing()) {
                dialog.show();
            }
            dialog.setMessage(getText(R.string.lbl_downloading) + " : " + String.valueOf(mCount) + " / " + String.valueOf(totalItems));
        }
    });
    

    this is a snipped taken from my code which displays the downnloaded items.

提交回复
热议问题