Materialdrawer: Dynamic Url issue

Created on 9 Jan 2018  路  5Comments  路  Source: mikepenz/MaterialDrawer

I am implementing Dynamic Url in Material Drawer. But The image is not showing.

I am using this code

public class UrlPrimaryDrawerItem extends PrimaryDrawerItem {
    @Override
    protected void bindViewHelper(BaseViewHolder viewHolder) {
        super.bindViewHelper(viewHolder);

        if(icon.getUri() != null) {
            ImageView imageView = (ImageView) viewHolder.itemView.findViewById(com.mikepenz.materialdrawer.R.id.material_drawer_icon);
            imageView.setVisibility(View.VISIBLE);
            ImageHolder.applyTo(icon, imageView);
        }
    }

    public UrlPrimaryDrawerItem withIcon(String url) {
        icon = new ImageHolder(url);
        return this;
    }
}

And I have added Item Like

 UrlPrimaryDrawerItem item = new UrlPrimaryDrawerItem().withIcon(image).withIdentifier(i+2).withName(LocalCategoriesClass.getElementStringByIndex(expandableCategoryList,i))
                    .withTypeface(StaticFunctions.getRobotoRegular(context)):
question

All 5 comments

I have implemented CustomUrlPrimaryDrawerItem but it shows some error at

    @Override
    public int getType() {
        return R.id.material_drawer_item_custom_url_item;
    }

Also I didnt Implemented DrawerImageLoader. I will implement it now. But can you tell me why it showing error in above line.

@abumoallim because you project does not contain that id I guess. :D

The id is just there to correctly identify a single drawerItemType for re-using it in the recyclerView. you can also define a hardcoded integer, as long as you are sure it's unique

https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/res/values/ids.xml

Thanks alot Mike, the Issue is solved.
Really appreciate your effort to this library.
Thanks again.

Thank you very much

Was this page helpful?
0 / 5 - 0 ratings

Related issues

singhalavi picture singhalavi  路  4Comments

pranjal-joshi picture pranjal-joshi  路  3Comments

jehad-suliman picture jehad-suliman  路  3Comments

Meeks91 picture Meeks91  路  3Comments

hosseiniSeyRo picture hosseiniSeyRo  路  3Comments