Java Code Examples for android.support.v4.widget.TextViewCompat#setCompoundDrawablesRelative()

The following examples show how to use android.support.v4.widget.TextViewCompat#setCompoundDrawablesRelative() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DrawerListAdapter.java    From monolog-android with MIT License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LvMenuItem item = mItems.get(position);
    switch (item.type) {
        case LvMenuItem.TYPE_NORMAL:
            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.listitem_drawer_menu_item, parent,
                        false);
            }
            TextView itemView = (TextView) convertView;
            itemView.setText(item.name);
            Drawable icon = mContext.getResources().getDrawable(item.icon);
            setIconColor(icon);
            if (icon != null) {
                icon.setBounds(0, 0, mIconSize, mIconSize);
                TextViewCompat.setCompoundDrawablesRelative(itemView, icon, null, null, null);
            }

            break;
        case LvMenuItem.TYPE_NO_ICON:
            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.listitem_drawer_subheader,
                        parent, false);
            }
            TextView subHeader = (TextView) convertView;
            subHeader.setText(item.name);
            break;
        case LvMenuItem.TYPE_SEPARATOR:
            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.listitem_drawer_seperator,
                        parent, false);
            }
            break;
    }

    return convertView;
}
 
Example 2
Source File: NavListViewActivity.java    From Android_Blog_Demos with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    LvMenuItem item = mItems.get(position);
    switch (item.type)
    {
        case LvMenuItem.TYPE_NORMAL:
            if (convertView == null)
            {
                convertView = mInflater.inflate(R.layout.design_drawer_item, parent,
                        false);
            }
            TextView itemView = (TextView) convertView;
            itemView.setText(item.name);
            Drawable icon = mContext.getResources().getDrawable(item.icon);
            setIconColor(icon);
            if (icon != null)
            {
                icon.setBounds(0, 0, mIconSize, mIconSize);
                TextViewCompat.setCompoundDrawablesRelative(itemView, icon, null, null, null);
            }

            break;
        case LvMenuItem.TYPE_NO_ICON:
            if (convertView == null)
            {
                convertView = mInflater.inflate(R.layout.design_drawer_item_subheader,
                        parent, false);
            }
            TextView subHeader = (TextView) convertView;
            subHeader.setText(item.name);
            break;
        case LvMenuItem.TYPE_SEPARATOR:
            if (convertView == null)
            {
                convertView = mInflater.inflate(R.layout.design_drawer_item_separator,
                        parent, false);
            }
            break;
    }

    return convertView;
}