Android AsyncTask未填充布局

Android AsyncTask未填充布局,android,android-layout,android-asynctask,Android,Android Layout,Android Asynctask,我有一个简单的线性布局,id为内容 我有一个其他的布局,一个相对的布局(id=entry)。根据php文件的响应,该相对值将膨胀几次 问题是,如果我手动将entrylayout充气4次,它工作正常。这是使用的代码: LinearLayout content = (LinearLayout) Events.this.findViewById(R.id.content); for (int i=0; i<4;i++){ RelativeLayout event = (R

我有一个简单的
线性布局
,id为
内容

我有一个其他的布局,一个相对的布局(id=
entry
)。根据php文件的响应,该相对值将膨胀几次

问题是,如果我手动将
entry
layout充气4次,它工作正常。这是使用的代码:

LinearLayout content = (LinearLayout) Events.this.findViewById(R.id.content);
    for (int i=0; i<4;i++){
        RelativeLayout event = (RelativeLayout) mInflater.inflate(R.layout.event_entry, null);
        content.addView(event);
    }
但它没有填充任何东西

尝试了类似
event.getParent().invalidate()之类的操作但结果相同

你明白发生了什么吗? 我看不出第一个示例代码和下面的实际代码之间有什么区别。请注意,循环应该循环两次

似乎永远不会触发onPostExecute:

protected String doInBackground(String... args) {
        // Building Parameters
        List<NameValuePair> params = new ArrayList<NameValuePair>();

        SharedPreferences settings = getSharedPreferences("login", MODE_PRIVATE);
        int loggedin = settings.getInt("logged", 0);
        if (loggedin == 0){
            Events.this.finish();
        }
        String username = settings.getString("username", "");
        String password = settings.getString("password", "");
        params.add(new BasicNameValuePair("username", username));
        params.add(new BasicNameValuePair("password", password));

        // getting JSON string from URL
        JSONObject json = jParser.makeHttpRequest(Events.this.urlWebRetrieveEvents, "POST", params);

        // Check your log cat for JSON reponse
        if (json!= null){
            //Log.d("Debugging", json.toString());
            try {
                int success = json.getInt("success");
                if (success == 1){
                    //this is filling hashmap correctly
                    Log.d("debugging","AQUI VAAA"+Events.this.events.toString());
                }
            } catch (Exception e){
                //algo malo. no internet? perdudes les dades? Crec que mai hauriem d'entrar aquí.
            }
        }
        return null;

    }
受保护的字符串doInBackground(字符串…args){
//建筑参数
List params=new ArrayList();
SharedReferences设置=获取SharedReferences(“登录”,模式\私有);
int loggedin=settings.getInt(“logged”,0);
如果(loggedin==0){
Events.this.finish();
}
stringusername=settings.getString(“username”,”);
String password=settings.getString(“password”,“password”);
添加(新的BasicNameValuePair(“用户名”,用户名));
添加(新的BasicNameValuePair(“密码”,password));
//从URL获取JSON字符串
JSONObject json=jParser.makeHttpRequest(Events.this.urlWebRetrieveEvents,“POST”,参数);
//检查日志cat中的JSON响应
if(json!=null){
//Log.d(“调试”,json.toString());
试一试{
int success=json.getInt(“success”);
如果(成功==1){
//这是正确填充hashmap
Log.d(“调试”,“AQUI VAAA”+Events.this.Events.toString());
}
}捕获(例外e){
//阿尔戈·马洛,没有互联网吗?你是说什么。
}
}
返回null;
}

有史以来最愚蠢的错误

我的任务如下:
类检索事件扩展异步任务{

因此,我必须使用如下覆盖实现onPostExecute:
受保护的void onPostExecute(字符串str){

以前是:
受保护的void onPostExecute(){

尝试更改

protected void onPostExecute() {


要先排除简单的问题…是否执行循环?Is
Events.this.Events.size()
>0?为什么要在条件中添加1?通常size方法返回从1开始的结果。0意味着空。@Gustek只是一些调试尝试,无论如何都不会有任何影响。我刚刚发现伙计们,
onPostExecute
从未被调用。那
Log.d(“调试”,“Omplo llistat amb”+事件。this.Events.toString())
未填充日志。如果执行,您将获得NLP;如果使用标准集合列表,则会获得IndexAutofBound。Post doInBackground和logcat。
protected void onPostExecute() {
protected void onPostExecute(Void result) {