E
E
eellazy2016-01-07 18:50:33
Java
eellazy, 2016-01-07 18:50:33

How to add icons to the menu?

Hello. How can I add an icon to each menu item?
Here is my menu

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        mDrawerListView = (ListView) inflater.inflate(
                R.layout.fragment_navigation_drawer, container, false);
        mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                selectItem(position);
            }
        });
        
        ArrayList<String> data = new ArrayList<>();
        data.add(getString(R.string.title_opened_auctions));
        data.add(getString(R.string.title_rent_tech));
        data.add(getString(R.string.title_buy_materials));
//        data.add(getString(R.string.title_check_contragent));
        data.add(getString(R.string.title_orders_history));
        data.add(getString(R.string.title_faq));
        data.add(getString(R.string.title_exit));
        adapter = new NavigationDrawerAdapter(getActivity(), data);
        mDrawerListView.setAdapter(adapter);
        mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
        return mDrawerListView;
    }

I've tried this but it doesn't work...
items.add(new NavigationItem("item 1", getResources().getDrawable(R.drawable.ic_menu_check)));

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question