Search in sources :

Example 1 with DefaultColorStateList

use of carbon.drawable.DefaultColorStateList in project Carbon by ZieIony.

the class BottomBar method setMenu.

public void setMenu(Menu menu) {
    this.menu = menu;
    content.removeAllViews();
    content.setWeightSum(menu.size());
    for (int i = 0; i < menu.size(); i++) {
        final MenuItem item = menu.getItem(i);
        final View view = View.inflate(getContext(), R.layout.carbon_bottombar_item, null);
        view.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (view == activeView)
                    return;
                if (activeView != null) {
                    deselectItem(activeView);
                }
                selectItem(view);
                if (listener != null)
                    listener.onMenuItemClick(item);
            }
        });
        ImageView icon = (ImageView) view.findViewById(R.id.carbon_bottomIcon);
        icon.setTint(new DefaultColorStateList(getContext()));
        icon.setImageDrawable(item.getIcon());
        TextView text = (TextView) view.findViewById(R.id.carbon_bottomText);
        text.setTextColor(new DefaultColorStateList(getContext()));
        text.setText(item.getTitle());
        content.addView(view, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1));
    }
}
Also used : MenuItem(android.view.MenuItem) View(android.view.View) DefaultColorStateList(carbon.drawable.DefaultColorStateList)

Aggregations

MenuItem (android.view.MenuItem)1 View (android.view.View)1 DefaultColorStateList (carbon.drawable.DefaultColorStateList)1