【发布时间】:2013-04-21 16:11:26
【问题描述】:
我想在短时间内同时更改多个文本视图 (>30)。但是如果这些步骤很短(
public class AsyncChangeUI extends AsyncTask<Void, Integer, Void> {
View view;
int oldPercentage;
int newPercentage;
AsyncChangeUI(View view, int oldPercentage, int newPercentage){
super();
this.view = view;
this.oldPercentage = oldPercentage;
this.newPercentage = newPercentage;
}
@Override
protected Void doInBackground(Void... params) {
Log.e("Kachel", view.getClass().getName());
for(Integer i=this.oldPercentage; i<=newPercentage; i++){
this.oldPercentage = i;
try {
Thread.sleep(10); //laggy if <100
publishProgress(i);
}catch(InterruptedException e) {
e.printStackTrace();
}
}
return null;
}
@Override
protected void onProgressUpdate(Integer... progress) {
List<TileGroupLayout> tileGroupList = ((MainLinearLayout) view).tileGroupList;
for (TileGroupLayout tileGroup: tileGroupList) {
List<TileLayout> tileList = tileGroup.tileList;
for (TileLayout tile: tileList) {
tile.changePercentageTo(progress[0]);
}
}
}
}
谢谢! 我注意到改变的最后一步比第一步更滞后:S
【问题讨论】:
标签: android animation asynchronous