如何在从其他活动恢复时保持标签图标处于正常阶段?
这是用于标签布局的代码:
public void initViews(View v) {
//Adding toolbar to the activity
//Initializing the tablayout
tabLayout = (TabLayout) v.findViewById(R.id.tabLayout);
db = new DatabaseHandler(getActivity());
userid = Util.getUserObject(getActivity(), Constants.KEY_ID);
//Adding the tabs using addTab() method
tabLayout.setupWithViewPager(viewPager);
tabLayout.addTab(tabLayout.newTab());
tabLayout.addTab(tabLayout.newTab());
tabLayout.addTab(tabLayout.newTab());
tabLayout.getTabAt(0).setCustomView(prepareTabItem(0, R.drawable.home_selector));
tabLayout.getTabAt(1).setCustomView(prepareTabItem(1, R.drawable.message_selector));
tabLayout.getTabAt(2).setCustomView(prepareTabItem(2, R.drawable.cmnt_selector));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
viewPager = (ViewPager) v.findViewById(R.id.pager);
menu = (LinearLayout) v.findViewById(R.id.menu);
search = (LinearLayout) v.findViewById(R.id.search);
searchIcon = (ImageView) v.findViewById(R.id.search_icon);
searchIcon.setTag("0");
mainLayout = (RelativeLayout) v.findViewById(R.id.main_layout);
}