Home > OS >  i'm getting this error can someone help me out **illegal start of expression
i'm getting this error can someone help me out **illegal start of expression

Time:09-13

I'm using the fragment but getting this error illegal start of expression?

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
      View view = return inflater.inflate(R.layout.fragment_frag1, container, false);
      return view;
    }
}

CodePudding user response:

It is a syntax error. There is a return in your assignment. You can either remove it or do not assign the result of the method to a new Object and return the result directly.

View view = inflater.inflate(R.layout.fragment_frag1, container, false);
return view;
return inflater.inflate(R.layout.fragment_frag1, container, false);

CodePudding user response:

 @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
      View view = inflater.inflate(R.layout.fragment_frag1, container, false);
      return view;
    }
}

try this remove return from inflater

  • Related