I am trying to create an ImageView in a Fragment which will refer to the ImageView element which I have created in the XML for the Fragment. However, the findViewById<
You can override onViewCreated() which is called right after all views had been inflated. It's the right place to fill in your Fragment's member View
variables. Here's an example:
class GalleryFragment extends Fragment {
private Gallery gallery;
(...)
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
gallery = (Gallery) view.findViewById(R.id.gallery);
gallery.setAdapter(adapter);
super.onViewCreated(view, savedInstanceState);
}
}