我试图通过设置的值在 android 中setOnGroupClickListener禁用。ExpandableListViewasynctask expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView expandableListView, View view, int i, long l) { try { new checkProgressValue().execute(i).get(3000,TimeUnit.MILLISECONDS); } catch (Exception e) { e.printStackTrace(); } Log.i("ResultPermission", String.valueOf(permission)); if (permission.equals(false)) { return false; } else { eturn true; } } });异步任务代码:public class checkProgressValue extends AsyncTask<Integer, Void, Void> { @Override protected Void doInBackground(Integer... voids) { Call<DefaultResponse> call = RetrofitClient.getInstance().getApi() .checkQuizTopicForAttempt(user.getId(), topicList.get(voids[0]).getCourse_id()); final int temp = voids[0]; call.enqueue(new Callback<DefaultResponse>() { @Override public void onResponse(Call<DefaultResponse> call, Response<DefaultResponse> response) { try { if (response.body().getMessage() == null) { progressValue = 0; } 程序不会在execute(i).get()方法处等待,并且始终返回 true。该方法中的Log.i打印权限为true,而打印权限为AsyncTaskfalse。我没明白我错在哪里。或者我有什么方法可以处理onClick吗PostExecute?
1 回答
慕桂英546537
TA贡献1848条经验 获得超10个赞
只需在以下位置调用此函数onResponse
:
expandableListView.expandGroup(positionOfGroup);
添加回答
举报
0/150
提交
取消