I am trying to follow ImageView and GalleryView tutorial and add a galleryview in a fragment class however there is an error that the ImageAdapter cannot be applied to the Tab1F
It needs a Context not a Fragment. Use this new ImageAdapter(getActivity())
First of all, you should move the return line return inflater.inflate(R.layout.tab2, container, false);
to end of your onCreateView, because all other lines will be unreachable.
Also, you should correct the onCreateView this way :
View view = inflater.inflate(R.layout.tab2, container, false);
GridView gridview = (GridView) view.findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(getActivity());
.
.
.
return view ;
You should pass a context to it. You can use the getActivity()
. Also you are missing a closing parenthesis. So, replace the wrong line with
new ImageAdapter(getActivity()) ;