0
我想在短时间内同时更改多个文字浏览(> 30)。但如果这些步骤很短(< 100毫秒),则变化非常缓慢。我想实现~10ms。即时通讯调试联系4.是行为正常吗? 继承人我的代码:Android更改多个UI元素
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]);
}
}
}
}
thx! 我注意到改变的最后步骤比第一步更迟缓:S
这应该是评论 – codeMagic 2013-04-21 16:18:29
是的,没有任何影响。你知道这个影响有多强大吗? – user2304753 2013-04-21 16:23:52