Home > Mobile >  Navigationview + fragments: why switch after a fragment, the item can't click. Navigation monit
Navigationview + fragments: why switch after a fragment, the item can't click. Navigation monit

Time:09-20

Fragment is not aware of the problem was the problem of navigation, pressed for time, save the children
 navCehua. SetNavigationItemSelectedListener (new NavigationView OnNavigationItemSelectedListener () {
@ Override
Public Boolean onNavigationItemSelected (@ NonNull MenuItem MenuItem) {
The switch (menuItem getItemId ()) {
Case R.i d.i t_Upload:
TvTitle. SetText (" upload the wrong topic ");
SwitchFrag (fr_u);
Toast. MakeText (MainActivity. This menuItem. GetTitle (), toString (), Toast. LENGTH_SHORT), show ();
break;
Case R.i d.i t_Calendar:
TvTitle. SetText (" exam calendar ");
SwitchFrag (fr_c);
break;
Case R.i d.i t_Text:
TvTitle. SetText (" wrong topic test ");
SwitchFrag (fr_t);
Toast. MakeText (MainActivity. This menuItem. GetTitle (), toString (), Toast. LENGTH_SHORT), show ();
break;
Case R.i d.i t_Analyse:
TvTitle. SetText (" atlas analysis ");
SwitchFrag (fr_a);
break;
}

//navCehua. GetMenu (). The clear ();
//navCehua. InflateMenu (R.m emu. Cehua_menu);
//navCehua. GetMenu (.) findItem (menuItem. GetItemId ()). SetChecked (true);
The drawer. CloseDrawer (Gravity. LEFT);
return true;
}
});

}


//conversion fragments
Public void SwitchFrag (fragments targetFragment) {

FragmentTransaction transaction=getSupportFragmentManager (). The beginTransaction ();
//if the Fragment is not to add, add, or show
if(! TargetFragment. IsAdded ()) {

Transaction. Hide (currentFragment). The add (R.i d.d l_cebian, targetFragment), commit ();
}
The else {
Transaction. Hide (currentFragment.) the show (targetFragment). The commit ();
}
CurrentFragment=targetFragment;
}



CodePudding user response:

Man asked the wrong place, how run Android to iOS,
  •  Tags:  
  • iOS
  • Related