How to call an activity from on Itemclick listener : I am trying to call an activity when ever an element from my gridview is clicked
it will open in a swiping activity but I am getting an error on setting 
as
       
    2829-2829/com.union.project E/AndroidRuntime: FATAL EXCEPTION: main
                                                                 Process: com.union.project, PID: 2829
                                                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.union.project/com.union.project.Swipeview.Main3Activity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
                                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                     at android.os.Looper.loop(Looper.java:135)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at java.lang.reflect.Method.invoke(Method.java:372)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                                                                  Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
                                                                     at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:302)
                                                                     at android.app.Activity.requestWindowFeature(Activity.java:3605)
                                                                     at com.union.project.Swipeview.Main3Activity.onCreate(Main3Activity.java:19)
                                                                     at android.app.Activity.performCreate(Activity.java:5990)
                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
                                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
                                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                     at android.os.Looper.loop(Looper.java:135) 
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                                     at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
04-27 00:39:27.626 2829-2829/com.union.pro
this is the error I am getting when I click on anyitem it show the toast but then crashes my fragment code

     @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view= inflater.inflate(R.layout.fragment_two, container, false);
        GridView gridView=(GridView)view.findViewById(R.id.gridView2);
        gridView.setAdapter(new UAdapter(getActivity()));
        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Toast.makeText(getActivity(),"Pic"+(position)+"Selected",Toast.LENGTH_SHORT).show();
                Intent intent= new Intent(view.getContext(),Main4Activity.class);
                intent.putExtra("pic",position);
                startActivity(intent);
            }
        });
        return view;
    }
my swipe view code ` 

     protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main4);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        viewPager =(ViewPager)findViewById(R.id.viewpager1);
        adapter =new CustomeSwipeAdapter2(this);
        viewPager.setAdapter(adapter);
        viewPager.setCurrentItem(getIntent().getIntExtra("pic", 0));
    }`
this is the activity that I want to start but getting the error can some one tell me how to fix this .
