【问题标题】:Android change multiple UI elementsAndroid更改多个UI元素
【发布时间】: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


    【解决方案1】:

    您是否在未连接调试器的情况下尝试过此操作?调试器确实会降低您的应用程序的速度。

    【讨论】:

    • 是的,没有任何效果。你知道效果可能有多大的百分比吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-10
    • 1970-01-01
    • 2015-04-06
    • 1970-01-01
    相关资源
    最近更新 更多