1

我想在Fragment中使用AsyncTask并在 AsyncTask findViewById中使用。

  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.category, 
            container, false); 


    View myFragmentView = inflater.inflate(R.layout.category, container, false);
    cont=getActivity();

    new ProgressTask(cont, myFragmentView).execute();
}




private class ProgressTask extends AsyncTask <Void,Void,Void>{
    private Context mContext;
    private View rootView;

    public void RecuperarComentarisFoto(Context context, View rootView){
        this.mContext=context;
        this.rootView=rootView;
    }

    LinearLayout barLayout = (LinearLayout) rootView.findViewById(R.id.barLayout);
    [...]

他对我说 cont=getActivity(); 无法解析为变量。我应该继续设置什么?

谢谢

4

0 回答 0