1
我想通过搜索找出自己出了什么问题,但是我错过了其他的东西,我想。AsyncTask - onPostExecute UI混淆
我有一个doInBackground类,它为我检查某些东西,并返回TRUE或FALSE到onPostExecute。通过调试,我发现代码正在工作,param通过函数发送并且逐行正在工作,但UI没有更新他们必须的地方。
这里是我的代码部分:
class check extends AsyncTask<Void,Void,Boolean> {
@Override
protected Boolean doInBackground(Void... params) {
//some code here
if(tmp.equals(SSID)){
return true;
} else {
//little bit of code
return false;
}
}
@Override
protected void onPostExecute(Boolean is) {
super.onPostExecute(is);
if(is){
Button State = (Button) findViewById(R.id.State);
State.setBackgroundResource(R.drawable.shape_ringcnt);
} else {
Button State = (Button) findViewById(R.id.State);
State.setBackgroundResource(R.drawable.shape_ringnrdy);
}
}
}
我想我的代码是墙根无为有当然的UI,但如果一切都很好,我可以显示隐藏的部分。
你确定它正在运行代码onPostExecute – has19
如果是这样我认为你需要刷新视图 – has19
在setbackground后写入State.invalidate() – has19