Android fragments cont=getActivity()无法解析为变量

Android fragments cont=getActivity()无法解析为变量,android-fragments,android-asynctask,Android Fragments,Android Asynctask,我想在片段中使用异步任务并在AsyncTask中使用findViewById public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.category, container, false); View myF

我想在片段中使用异步任务并在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);
    [...]
public View onCreateView(布局、充气机、视图组容器、,
Bundle savedInstanceState){
视图=充气机。充气(右布局。类别,
货柜(虚假);;
查看myFragmentView=充气机。充气(R.layout.category,container,false);
cont=getActivity();
新建ProgressTask(cont,myFragmentView).execute();
}
私有类ProgressTask扩展了AsyncTask{
私有上下文;
私有视图rootView;
public void Reciperarcomentarisfoto(上下文上下文,视图根视图){
this.mContext=上下文;
this.rootView=rootView;
}
LinearLayout barLayout=(LinearLayout)rootView.findViewById(R.id.barLayout);
[...]
他对我说,cont=getActivity();不能解析为变量。 我应该为cont设置什么

谢谢