Extend com.mikepenz.materialdrawer.AccountHeaderBuilder - android

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 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)

Related

Kotlin layout id is showing two imports

I imported a module to my project. That module was working in my sample,
But in my app this is showing two imports, Can someone let me know, why did this happen. And what will be its solution. Because I never imported the ids in kotlin, so why I faced this behaviour now?
Please note:
It is not about one id drawer_layout, all my ids are showing two imports, Also please note that I never imported all these ids in my old sample project. But in my other app, all ids are showing two imports.
Edit
I am adding some additional screenshots for better understanding.
No duplicate id
But showing two imports
All ids are showing two imports in class (Almost 100 erros in class)
it's automatic in kotlin. You just have to choose kotlinx.android.synthetic
I've tried it in fragments and it can't. when in fragment you still have to use findViewById
So if you have a view in the xml layout with id = drawer_layout, there are two imports:
acr.browser.lightning.R.id.drawer_layout : This is the ID mapping that you will find in your R.java file. You will have an entry for every view there. This import exists even when you are not using kotlin. You will use this, for example, when you want to compare the View Id to determine which View is clicked, etc...
kotlinx.android.synthetic.main.activity_main.drawer_layout : Now this is the way by which you can access the VIEW without using findViewById and reference it directly.
Looking at your code, I see that the 2nd import is what you need to choose. It's normal for the IDE to show both the imports, because both are valid. Now, there is a bug in Android Studio (at least in the 3.1 version), where even when you choose the 2nd import, sometimes Android Studio will show ALL THE ID's as errors (since it won't recognize the synthetic import). To resolve this you need to Build the app again, and the errors will go away (if the synthetic import is still present)

Android xml in app cannot find custom view in module

Sorry for the dumb question, I'm doing one module for many app.
I create a custom view class in the my module (public class CustomView extends FrameLayout).
I have imported this modules into app and class in the app can call my custom view, but xml cannot call my custom view (compile project(':mymodule')).
I have not found a solution, thank all the help.
Make sure that your module gradle has a same compileSdkVersion, buildToolsVersion as your app gradle. Also it might be beneficial to ensure that you are using same support libraries.
if compileSdkVersion, buildToolsVersion is set properly you should not have any issues to find you custom view in your xml file (in case if you did not, try to use you application context in xml)

I need QuickReturnView for gridview like sample ListView. Can anyone help me?

Can anyone have sample about quickreturnview gridview ? I used https://github.com/LarsWerkman/QuickReturnListView. but I have a bug when scrolling in gridview. Can you help me ?
I suggest you use alternative library (alike the one from your question) i.e. this one: https://github.com/allminewuwei/QuickReturnView
What you need to do is:
1. Download the library and import it in your workspace (I'm using eclipse terms, to the analog action in Android Studio)
2. Copy paste the two classes (shown in the screenshot) from the library project in to your project.
It would be neat if you open a separate package (smt like: com.yourapp.quickretrun)
resolve the issues (quick fix tips should do the trick)
Rename the QuickReturnListView class that you've imported in you project into QuickReturnGridView (or anything that will imply the nature of the widget) and do this change:
public class QuickReturnGridView extends GridView {
/*can extend any class that is extended from
don't change anything else within the class */
}
Lastly in the layout that you're going to make use of the newly created component, make sure that you follow this hierarchy (must have the exact layout_width and layout_height values) :

Android how to remove gridlayout from the project?

I added grid layout to my project at the start and eclipse added a bunch of stuff. Now, though I am not using this layout. I want to remove it.
I can see the following from my properties file:
target=android-18
android.library.reference.1=../gridlayout_v7
When I remove the line
android.library.reference.1=../gridlayout_v7
I get compile errors relating to my R.java class.
I cannot seem to find a proper way to remove this package. Anybody knows how to do this?
Thanks!
#Nightshadow please right click on project and select properties and then select android now you will able to see Library pane in below area from there you can remove grideview layout library

Customizing a project library in Android

I'm using this library project in my Android application. But I need to make some customization for it.
For example, if I need a EditText instead of the provided TextView, what is the best practice to customize the library for my needs without writing code in the Project Library?
I made this customization by defining in the library's actionbar.xml layout a EditText instead of TextView, but I don't like this approach.
Do you have any guidelines, tutorials that could help me out?
In your special case I would suggest to use original compatibility's-package actionBar.
But to answer your question: you could always extend classes from the Library, which I think is the best practice if the library should kept untouched. Overriding Methods which you want to change their behavior keeps anything clean. You do the exact same every time you extend android-sdk classes, which you cannot change like you want.
In the case of changing layouts I'm not quite shure. I think I can remember that if the lib has an actionbar.xml and you have an actionbar.xml inside your project, too, yours will win. just like an "overriding layouts" feature

Categories

Resources