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)):
@abumoallim the sample contains such a custom item:
https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/java/com/mikepenz/materialdrawer/app/drawerItems/CustomUrlPrimaryDrawerItem.java
Do you have a DrawerImageLoader defined?
https://github.com/mikepenz/MaterialDrawer#load-images-via-url
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