0

i want to disable the menu option when i launch the fragments but when i go back to the home screen i want the option to be visible.i tried to set visibility to true in onresume but it gives an null pointer exception

 public boolean onNavigationItemSelected(MenuItem paramMenuItem)
   {
FragmentManager localFragmentManager = getSupportFragmentManager();
WebViewFragment localWebViewFragment = new WebViewFragment();
ContactUsFragment contactus = new ContactUsFragment();
Bundle localBundle = new Bundle();

switch (paramMenuItem.getItemId())
{
  case R.id.signin:localFragmentManager.beginTransaction().replace(R.id.frame_replace, new SignInFragment()).addToBackStack("signIn").commit();
    break;

  case R.id.drawer_book_your_car:
    if ((PrefUtils.getDefaults("isSignedIn", this.mContext) == null) || (PrefUtils.getDefaults("isSignedIn", this.mContext).equalsIgnoreCase("false")) || (PrefUtils.getDefaults("isSignedIn", this.mContext).equalsIgnoreCase("")))
    {
      Toast.makeText(this.mContext, "Please Sign In", Toast.LENGTH_LONG).show();
      return true;
    }
    break;


  case R.id.drawer_myTrip:localFragmentManager.beginTransaction().replace(R.id.frame_replace, new TripFragment()).addToBackStack("MyTrip").commit();
    break;


  case R.id.drawer_tariff:startActivity(new Intent(this.mContext, TariffActivity.class));
    break;

  case R.id.how_to_broom:
    localBundle.putString("url","www.abc.com");
    localWebViewFragment.setArguments(localBundle);

    localFragmentManager.beginTransaction().replace(R.id.frame_replace,localWebViewFragment).addToBackStack("web").commit();
    localMenuItem.setVisible(false);
    break;
  case R.id.drawer_FAQs:
    localBundle.putString("url","www.abc.com");
        localWebViewFragment.setArguments(localBundle);
        localFragmentManager.beginTransaction().replace(R.id.frame_replace, localWebViewFragment).addToBackStack("web").commit();
        localMenuItem.setVisible(false);
        break;
    case R.id.drawer_policies:
    localBundle.putString("url","www.abc.com");
    localWebViewFragment.setArguments(localBundle);
    localFragmentManager.beginTransaction().replace(R.id.frame_replace,localWebViewFragment).addToBackStack("web").commit();
    localMenuItem.setVisible(false);
    break;

  case R.id.contactUs:
    localBundle.putString("url", "www.abc.com");
    localWebViewFragment.setArguments(localBundle);
    localFragmentManager.beginTransaction().replace(R.id.frame_replace,contactus).addToBackStack("web").commit();
    break;


}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT) {
  ((DrawerLayout)findViewById(R.id.drawer_layout)).closeDrawer(GravityCompat.START);
}
return true;

   }
    public void onResume(){
    super.onResume();
    localMenuItem.setVisible(false);



   }

0 Answers0