@Override public void onClick(View v) { switch (v.getId()) { case R.id.menu_categ_tab: fragment = new MenuItems(); Defaults.replaceFragment(fragment, getActivity()); break; case R.id.nearby_categ_tab: fragment = new Nearby(); Defaults.replaceFragment(fragment, getActivity()); break; case R.id.novelty_categ_tab: fragment = new Novelty(); Defaults.replaceFragment(fragment, getActivity()); break; case R.id.favor_categ_tab: fragment = new Favourites(); Defaults.replaceFragment(fragment, getActivity()); break; case R.id.reservation_categ_tab: fragment = new Reservation(); Defaults.replaceFragment(fragment, getActivity()); break; case R.id.categories_categ_tab: fragment = new Categories(); Defaults.replaceFragment(fragment, getActivity()); break; case R.id.searchViewCategories: search_view_main.onActionViewExpanded(); break; default: break; } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_categories, container, false); ((MainActivity) getActivity()).getSupportActionBar().setTitle("Категории"); Defaults.setSearchViewStyle(R.id.searchViewCategories, rootView, getActivity()); // Initialize tab menu icons menu_categ_tab = (TextView) rootView.findViewById(R.id.menu_categ_tab); nearby_categ_tab = (TextView) rootView.findViewById(R.id.nearby_categ_tab); novelty_categ_tab = (TextView) rootView.findViewById(R.id.novelty_categ_tab); favor_categ_tab = (TextView) rootView.findViewById(R.id.favor_categ_tab); reservation_categ_tab = (TextView) rootView.findViewById(R.id.reservation_categ_tab); categories_categ_tab = (TextView) rootView.findViewById(R.id.categories_categ_tab); search_view_main = (SearchView) rootView.findViewById(R.id.searchViewCategories); elvCategories = (ExpandableListView) rootView.findViewById(R.id.elvCategories); elvCategories.setAdapter(new CategoriesAdapter(getActivity())); elvCategories.setOnChildClickListener( new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick( ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { Bundle bundle = new Bundle(); bundle.putInt("groupPosition", groupPosition); bundle.putInt("childPosition", childPosition); fragment = new CategoriesChildList(); fragment.setArguments(bundle); Defaults.replaceFragment(fragment, getActivity()); return true; } }); // Set OnClickListener to menu icons menu_categ_tab.setOnClickListener(this); nearby_categ_tab.setOnClickListener(this); novelty_categ_tab.setOnClickListener(this); favor_categ_tab.setOnClickListener(this); reservation_categ_tab.setOnClickListener(this); categories_categ_tab.setOnClickListener(this); search_view_main.setOnClickListener(this); return rootView; }