I am using TabLaout in Activity , but it showing NULL pointer : <p>This is my code </p>

<pre><code>  package com.saverx.rushabh.saverx;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.view.ViewGroup;


public class MainActivity extends AppCompatActivity {


    View view;
    private static final String ARG_SECTION_NUMBER = "section_number";
    ViewPager viewPager;
    //TabLayout tabLayout;
    TabLayout tabLayout;
    LayoutInflater inflater;
    ViewGroup container;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
         this.container=container;
         this.inflater=inflater;
        this.view= inflater.inflate(R.layout.activity_main, container, false);
        viewPager=(ViewPager)view.findViewById(R.id.viewPager);
        viewPager.setAdapter(new sliderAapter(getSupportFragmentManager()));
        tabLayout=(TabLayout)view.findViewById(R.id.sliding_tab);
        tabLayout.post(new Runnable() {
            @Override
            public void run() {
                tabLayout.setupWithViewPager(viewPager);
            }
        });








        //return view;
    }

    private class sliderAapter extends FragmentPagerAdapter {


        public sliderAapter(FragmentManager supportFragmentManager) {
            super(supportFragmentManager);
        }

        @Override
        public Fragment getItem(int position) {
            Log.e("adapter", ""+position);
            //  return new CalendarFragment();
            NewLeadsFragment obj= new NewLeadsFragment();
          /*  Bundle bundle=new Bundle();
            bundle.putInt("position",position);
            obj.setArguments(bundle);
            return obj;*/
          return obj;

        }

        @Override
        public int getCount() {
            return 3;// 3 tabs
        }


        @Override
        public CharSequence getPageTitle(int position) {
            switch (position) {
                case 0:
                    return "Leads";
                case 1:
                    return "Meetings";
                case 2:
                    return "Service";
            }
            return null;
        }

    }



}
</code></pre>

<p>Exception is </p>

<pre><code>  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean)' on a null object reference
                                                       at com.saverx.rushabh.saverx.MainActivity.onCreate(MainActivity.java:33)
</code></pre>

<p>This code is working perfectly fine when I am using fragment instad of activity</p>

<p>I am using tablayout so that i can drag through signup and sign in using tablayout.</p>

<p>The runtime error is :</p>

<p>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.saverx.rushabh.saverx/com.saverx.rushabh.saverx.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean)' on a null object reference</p>

<p>I summarise that the error may be due to I havent inserted <code>this.view=view</code> but it is throwing same exception </p>
