enter image description hereHow can I set the side bar menu item selected when fragment changes on click of the back button. I have custom textview and layouts in side bar: I tried this onBackStackChanged() method onBack press on Main activity of fragment, but I get last fragment selected in menu
@Override
public void onBackStackChanged()
{
String Tag = " ";
Fragment fragment = getSupportFragmentManager().findFragmentByTag(Tag);
Log.e("frag",""+fragment);
if (Tag != null) {
switch (Tag) {
case "Dashboard":
menu_img_dashboard.setImageDrawable(getResources().getDrawable(R.drawable.iconactivedasboard));
menu_dashborad_ln.setBackgroundColor(getResources().getColor(R.color.colorTextPrimary));
menu_img_newproduct.setImageDrawable(getResources().getDrawable(R.drawable.iconnewproduct));
menu_newproduct_ln.setBackgroundColor(getResources().getColor(R.color.colormenugray));
menu_img_searchbycategory.setImageDrawable(getResources().getDrawable(R.drawable.iconsearch));
menu_searchbycategory_ln.setBackgroundColor(getResources().getColor(R.color.colormenugray));
menu_img_orderhistory.setImageDrawable(getResources().getDrawable(R.drawable.iconorederhistory));
menu_myorderhistory_ln.setBackgroundColor(getResources().getColor(R.color.colormenugray));
menu_img_myfavorite.setImageDrawable(getResources().getDrawable(R.drawable.iconfavourite));
menu_myfavorite_ln.setBackgroundColor(getResources().getColor(R.color.colormenugray));
menu_img_about.setImageDrawable(getResources().getDrawable(R.drawable.iconabout));
menu_about_ln.setBackgroundColor(getResources().getColor(R.color.colormenugray));
menu_img_helpdesk.setImageDrawable(getResources().getDrawable(R.drawable.iconhelpdesk));
menu_helpdesk_ln.setBackgroundColor(getResources().getColor(R.color.colormenugray));
Log.v("hy", "find the dash fragment");
break;}