@Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus && mNavigationBar.isShown()) { mNavigationBar.hide(); } else if (!hasFocus && !mNavigationBar.isShown()) { mNavigationBar.show(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_round_tab); ButterKnife.bind(this); mNavigationBar .setDisplayBackButton(true) .setBackButtonImageResource(R.drawable.ic_chevron_left_white_24dp) .setBackButtonText("Back") .setOnBackButtonClickListener( new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }) .addItem(0, "Settings", ActivityCompat.getDrawable(this, R.drawable.ic_settings_white_24dp)) .addItem(1, "More", ActivityCompat.getDrawable(this, R.drawable.ic_more_vert_white_24dp)) .setOnMenuItemClickListener( new NavigationBar.OnMenuItemClickListener() { @Override public void onMenuItemClick(int id) { Toast.makeText(getApplicationContext(), "" + id, Toast.LENGTH_SHORT).show(); } }) .setTabs(new String[] {"music", "video", "games"}) .setOnTabCheckedListener( new NavigationBar.OnTabCheckedListener() { @Override public void onTabChecked(int position) { Toast.makeText( getApplicationContext(), "Tab " + position + " is checked", Toast.LENGTH_SHORT) .show(); } }) .bindViewPager(mViewPager); mFragmentList.add(TabFragment.newInstance(TAB_NANES[0])); mFragmentList.add(TabFragment.newInstance(TAB_NANES[1])); mFragmentList.add(TabFragment.newInstance(TAB_NANES[2])); mViewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(mViewPagerAdapter); mSearchView.setImeOption(EditorInfo.IME_ACTION_SEARCH); mSearchView.setOnEditorActionListener(mOnEditorActionListener); mSearchView.setOnFocusChangeListener(mOnFocusChangeListener); mSearchView.setButtonTextColor(BG_COLOR); mSearchView.setHint("Search"); mSearchView.setHintTextColor(0xFF8E8E93); mSearchView.setButtonText("Cancel"); mSearchView.setStyle(SearchView.Style.ROUND); }