0

我在 asynctask 中有一个解析函数,但出现此错误:

11-13 22:43:02.485: E/AndroidRuntime(12353): FATAL EXCEPTION: main
11-13 22:43:02.485: E/AndroidRuntime(12353): java.lang.NullPointerException
11-13 22:43:02.485: E/AndroidRuntime(12353):    at com.android.formazionifantacalcio.Juve$parsingformazioni.onPostExecute(Juve.java:101)
11-13 22:43:02.485: E/AndroidRuntime(12353):    at com.android.formazionifantacalcio.Juve$parsingformazioni.onPostExecute(Juve.java:1)
11-13 22:43:02.485: E/AndroidRuntime(12353):    at android.os.AsyncTask.finish(AsyncTask.java:631)
11-13 22:43:02.485: E/AndroidRuntime(12353):    at android.os.AsyncTask.access$600(AsyncTask.java:177)
11-13 22:43:02.485: E/AndroidRuntime(12353):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
11-13 22:43:02.485: E/AndroidRuntime(12353):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-13 22:43:02.485: E/AndroidRuntime(12353):    at android.os.Looper.loop(Looper.java:137)
11-13 22:43:02.485: E/AndroidRuntime(12353):    at android.app.ActivityThread.main(ActivityThread.java:5289)
11-13 22:43:02.485: E/AndroidRuntime(12353):    at java.lang.reflect.Method.invokeNative(Native Method)
11-13 22:43:02.485: E/AndroidRuntime(12353):    at java.lang.reflect.Method.invoke(Method.java:525)
11-13 22:43:02.485: E/AndroidRuntime(12353):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
11-13 22:43:02.485: E/AndroidRuntime(12353):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
11-13 22:43:02.485: E/AndroidRuntime(12353):    at dalvik.system.NativeStart.main(Native Method)

我认为这是当我试图在 postexecute 的列表视图中获取所有解析结果时,就像这样:

protected void onPostExecute(String result)
            {

                Formazioniadapter adapter = new Formazioniadapter(Juve.this, Juventus);
                listView.setAdapter(adapter);   
             }

这是我定义的适配器:

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class Formazioniadapter extends ArrayAdapter<String>{

    //riferimenti statici alle risorse e agli id
    private final static int TITOLO = R.layout.list_item;

    ArrayList<String> giocatori; //lista dei giocatori

    Context context; //context
    LayoutInflater inflater; //layout inflater

    public Formazioniadapter(Context context, ArrayList<String> giocatori)
    {
            super(context,TITOLO);
            this.context = context;
            this.giocatori = giocatori;
    }

    /*private view holder class*/
    private class ViewHolder {
        TextView txtTitle;
    }


    @Override
    public View getView(int position,View convertView,ViewGroup parent){
    ViewHolder holder = null;

    LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.list_group, null);
        holder = new ViewHolder();
        holder.txtTitle = (TextView) convertView.findViewById(R.id.text1);
        convertView.setTag(holder);
    } else
        holder = (ViewHolder) convertView.getTag();



    return convertView;
    }
}

谁能帮我找到问题?我要疯了。谢谢!

4

0 回答 0