Code example for LayerDrawable

Methods: getDrawable

0
            textView.setText(cursor.getString(TracksQuery.TRACK_NAME));
 
            // Assign track color to visible block 
            final View iconView = view.findViewById(android.R.id.icon1);
            LayerDrawable iconDrawable = (LayerDrawable) iconView.getBackground();
            iconDrawable.getDrawable(0).setColorFilter(
                    cursor.getInt(TracksQuery.TRACK_COLOR), PorterDuff.Mode.SRC_ATOP);
        } 
    } 
 
    /** {@link Tracks} query parameters. */ 
    private interface TracksQuery { 
        String[] PROJECTION_WITH_SESSIONS_COUNT = {
                BaseColumns._ID,
                Tracks.TRACK_ID, 
                Tracks.TRACK_NAME, 
                Tracks.TRACK_COLOR, 
                Tracks.SESSIONS_COUNT, 
        }; 
 
        int _ID = 0;