AsyncHttpRequest的Android加载屏幕

时间:2012-07-19 09:42:22

标签: android eclipse loader

我的应用中有一个列表,通过http请求填充到我们的数据库API。然后它解析返回的JSONArray,并适当地设置列表。顺便说一句,我对Java编码和eclipse环境都很陌生。

我已经使用loopj(位于here

开发的自定义库实现了http请求

但是,当我进入我的应用程序列表时,它会冻结一两秒(当它收集数据时),然后填充此列表,一切正常。是否可以实现一个加载器,该加载器将显示,直到列表完成加载我正在使用的当前AsyncHttpClient?或者我需要换到另一个。由于合同协议,我无法提供任何代码。

感谢您的任何建议!

1 个答案:

答案 0 :(得分:1)

我在Async类中做了类似的事情

public class Async extends AsyncTask {
    private ProgressDialog dialog;
    public Context applicationContext;

    @Override
    protected void onPreExecute() {
            //this should appear like a loading bar
        this.dialog = ProgressDialog.show(applicationContext, "Calling",
                "Update List ...", true);
    }

    @Override
    protected Object doInBackground(Object... params) {
            //call your method and threat response
        return SyncActivity.getUpdatedList();

    }

    @Override
    protected void onPostExecute(Object result) {
        this.dialog.cancel();
    }

}
相关问题