Skip to content Skip to sidebar Skip to footer

How To Call Setcontentview Method From A Fragment Class?

I want to add the coverflow object in this class and I don't find any way to solve it. I am new in Android development. public class NoticeEvents extends Fragment { View android;

Solution 1:

You don't set content view in Fragments. Instead you initialize your views and return it like you are already doing. So just remove this.setContentView(coverFlow); and it should work.

Solution 2:

Method setContentView is only used for activities.

When using fragments you should return the View in your onCreateView method.

@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ViewGroupandroid= (ViewGroup) inflater.inflate(R.layout.events, container, false);

    CoverFlow coverFlow;
    coverFlow = newCoverFlow(getContext());

    ImageAdaptercoverImageAdapter=newImageAdapter(getContext());

    coverImageAdapter.createReflectedImages();

    coverFlow.setAdapter(coverImageAdapter);

    coverFlow.setSpacing(-15);
    coverFlow.setSelection(8, true);


    android.addView(coverFlow);
    return android;
}

Post a Comment for "How To Call Setcontentview Method From A Fragment Class?"