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.
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 id
s 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 ImageView
s 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 TextView
s 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)