1

I need to build my own AccountHeaderBuilder implementation.

So I'm trying to extend a class from MaterialDrawer library. In Android studio, how do I need to proceed in order to do that? Should MaterialDrawer library be imported as a module?

If yes, why do I get errors like: Error:(1290) Error retrieving parent for item: No resource found that matches the given name 'MaterialTheme'. when I import the project as a module...

Even when my gradle is set to :

  compileSdkVersion 23
  minSdkVersion 15
  targetSdkVersion 23

My class extending AccountHeaderBuilder needs to be in the same package... So my understanding is that I cannot just use in the gradle file.

compile('com.mikepenz:materialdrawer:5.0.9@aar')

So, in one sentence : how to I proceed to be able to extend classes from another project?

Thanks a lot for the help

ps: I have been able to integrate this library and make it work in my project but now I need extra funcionalities.

Community
  • 1
  • 1
Greg
  • 689
  • 2
  • 8
  • 23
  • Why do you need to extend the `AccountHeaderBuilder`? What do you want to achieve? – mikepenz Mar 17 '16 at 13:51
  • I need to : 1: remove totally the icon for each profile. 2 : add additional information (better said TextView) below the Profile Name or email. Like for example: greg@gmail.com 2 Kids Married – Greg Mar 17 '16 at 14:03

1 Answers1

1

The exception occurs because the required dependencies are missing. The MaterialDrawer depends on the Materialize and FastAdapter libraries which provide required helper classes.

The documentation of the MaterialDrawer states to add transitive=true which will automatically resolve the sub dependencies of the MaterialDrawer

So replace your compile statement with:

compile('com.mikepenz:materialdrawer:5.1.4@aar') {
    transitive = true
}

As of the requirement mentioned in the comment. It is also possible to overwrite the layout used for the AccountHeader https://github.com/mikepenz/MaterialDrawer/blob/develop/library/src/main/res/layout/material_drawer_header.xml

You can alter that layout to anything you want, just remember the ids which are in need to stay the same, and you can't remove existing views like the profiles, but you could just alter it so the ImageViews are within a layout, and set this one to gone. So the profiles won't be visible anymore.

For the additional row. You can add this one to the selection container where the existing two TextViews are included. After that you just listen for the onProfileChanged event from the AccountHeaderBuilder, and update this TextView when the profile changes.

(You can get this view by searching for it with findViewById on the AccountHeader container view https://github.com/mikepenz/MaterialDrawer/blob/develop/library/src/main/java/com/mikepenz/materialdrawer/AccountHeader.java#L38)

mikepenz
  • 12,708
  • 14
  • 77
  • 117
  • Yes, I have that added, the problem I have occurs when I try to add the project as a Module. – Greg Mar 17 '16 at 14:05
  • if you add it as module, you will have to add all sub dependencies to your project. See my updated answer, how you could achieve your requirement without the need of adding the library as module. It has also an additional advantage, as it will still allow you to retrieve updates from the official repo – mikepenz Mar 17 '16 at 14:11
  • Thanks for the help Mike. Will try that right now :) And thanks a lot for the amazing job done with that library of yours ;) – Greg Mar 17 '16 at 14:24