title: Androidx Null Pointer Exception Error, Invoke method
body: <p>I am getting this error. This is my <code>logcat</code>. I don't know what exactly is wrong. I get revoke error or we can say <code>NullExceptionError</code>. I tried everything but nothing workout.</p>
  
  <pre><code> java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.RelativeLayout.setVisibility(int)' on a null object reference
      at com.nazeefawann.truemate.Profile.AccountSettingActivity.setViewPager(AccountSettingActivity.java:52)
      at com.nazeefawann.truemate.Profile.AccountSettingActivity$2.onItemClick(AccountSettingActivity.java:71)
      at android.widget.AdapterView.performItemClick(AdapterView.java:303)
      at android.widget.AbsListView.performItemClick(AbsListView.java:1151)
      at android.widget.AbsListView$PerformClick.run(AbsListView.java:3065)
      at android.widget.AbsListView$3.run(AbsListView.java:3878)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:135)
      at android.app.ActivityThread.main(ActivityThread.java:5538)
      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:960)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
  </code></pre>
  
  <p>I am making an app and I want to make fragment in the settings activity instead of separate so that I can add more feature easily. I have created the 2 fragment but when I click on it return back to the previous activity. I don't know why</p>
  
  <pre><code>public void setViewPager(int fragmentNumbers){
      mRelativeLayout.setVisibility(View.GONE);
      Log.d(TAG,"setViewPager: navigating to fragment #:" + fragmentNumbers);
      viewPager.setAdapter(pagerAdapter);
      viewPager.setCurrentItem(fragmentNumbers); 
  </code></pre>
  
  <p>this is my AccountSettingActivity </p>
  
  <pre><code> import androidx.annotation.Nullable;
   import androidx.appcompat.app.AppCompatActivity;
   import androidx.viewpager.widget.ViewPager;
  
  public class AccountSettingActivity extends AppCompatActivity {
  private Context mContext;
  private SectionStatePagerAdapter pagerAdapter;
  private ViewPager viewPager;
  private RelativeLayout mRelativeLayout;
  private String TAG;
  
  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      viewPager = (ViewPager) findViewById(R.id.container);
      mRelativeLayout = (RelativeLayout) findViewById(R.id.relaytiveLayout11);
      mContext = AccountSettingActivity.this;
      setContentView(R.layout.activity_accountsettings);
      setupSettingList();
      setupFragment();
      ImageView backArrow = (ImageView) findViewById(R.id.backArrow);
      backArrow.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              finish();
          }
      });
  }
  private void setupFragment(){
      pagerAdapter = new SectionStatePagerAdapter(getSupportFragmentManager());
      pagerAdapter.addFragment(new EditProfileFragment(), getString(R.string.edit_profile_fragment)); //fragment 0
      pagerAdapter.addFragment(new SignOutFragment(), getString(R.string.sign_out_fragment)); //fragment 1
  }
  public void setViewPager(int fragmentNumbers){
      mRelativeLayout.setVisibility(View.GONE);
      Log.d(TAG,"setViewPager: navigating to fragment #:" + fragmentNumbers);
      viewPager.setAdapter(pagerAdapter);
      viewPager.setCurrentItem(fragmentNumbers);
  
  }
  private void setupSettingList(){
      ListView listView = (ListView) findViewById(R.id.lvAccountSettings);
  
      ArrayList&lt;String&gt; options = new ArrayList&lt;&gt;();
      options.add(getString(R.string.edit_profile_fragment)); //fragment 0
      options.add(getString(R.string.sign_out_fragment)); //fragement 1
  
      ArrayAdapter adapter = new ArrayAdapter(mContext, android.R.layout.simple_list_item_1, options);
      listView.setAdapter(adapter);
  
      listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              setViewPager(position);
          }
      });
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>this is my xml file</p>
  
  <pre><code>&lt;androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
  &lt;include layout="@layout/layout_center_viewpager"&gt;&lt;/include&gt;
  &lt;RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/relaytiveLayout11"&gt;
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/relLayout2"&gt;
          &lt;include layout="@layout/snippet_top_settingtoolbar"/&gt;
  
      &lt;/RelativeLayout&gt;
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/relLayout3"
          android:layout_below="@id/relLayout2"
          android:layout_marginBottom="50dp"&gt;
  
          &lt;include layout="@layout/layout_center_accountsettiings"/&gt;
  
      &lt;/RelativeLayout&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>i am using android x library may i am getting error because of this library </p>
  
  <p>I am unable to find the error in this code I did a lot of experiment on it but nothing works out I am sure some of you would help me out 
  THANKS IN ADVANCE</p>