当 Activity 被破坏或暂停时如何恢复?
好吧,这就是我想做的......
new AsyncTask<Void, Integer, Void>(){
@Override
protected Void doInBackground(Void... arg0) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
text1.setText("Nice to meet you "+name);
dismissDialog(typeBar);
}
@Override
protected void onPreExecute() {
typeBar = 0;
showDialog(typeBar);
}
}.execute((Void)null);
}
});
}
问题是在我的应用程序中,textView 发生了很多变化!每次单击按钮时..我不想每次 textView 更改时都右击 AsyncTask。这将非常乏味并占用大量资源。有谁是我可以实现这个的更好方法吗?
Okay so here is what i am trying to do.....
new AsyncTask<Void, Integer, Void>(){
@Override
protected Void doInBackground(Void... arg0) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
text1.setText("Nice to meet you "+name);
dismissDialog(typeBar);
}
@Override
protected void onPreExecute() {
typeBar = 0;
showDialog(typeBar);
}
}.execute((Void)null);
}
});
}
The problem is in my app the textView changes ALOT!. Every time the button is clicked..I dont want to right an AsyncTask each time the textView changes. That will be to tedious and use to much resouce. Does anyone is it a better way i can implement this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这有点类似于我之前的帖子答案之一(相同的想法):
杀掉应用后如何保存闹钟?
This is kind of similar to one of my previous post answers (same idea):
How to save Alarm after app killing?