Good morning,
I followed all the driving and I was able to install the example on your smartphone, but when I click on "Dark Drawer" I get an error. I have attached a screenshot of the error. Where am I wrong?
I've download all of MSMaterialDrawer zip files, and test with my real device. I 've error log file. it couldn't run.
I try to build with Android sdk 23, B4A v6.0
when I try to run this ' MDB.Initialize("MD") '.
B4X:
Installing file.
PackageAdded: package:com.maximussoft.materialdrawer
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (actlight) Create, isFirst = true **
Cannot get methods of class: com.maximussoft.msmaterialdrawer.MSMaterialDrawerBuilder, disabling cache.
java.lang.VerifyError: com/mikepenz/materialdrawer/Drawer
at com.maximussoft.msmaterialdrawer.MSMaterialDrawerBuilder.Initialize(MSMaterialDrawerBuilder.java:57)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:748)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:343)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at com.maximussoft.materialdrawer.actlight.afterFirstLayout(actlight.java:102)
at com.maximussoft.materialdrawer.actlight.access$000(actlight.java:17)
at com.maximussoft.materialdrawer.actlight$WaitForLayout.run(actlight.java:80)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5072)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
** Activity (actlight) Resume **
An error occurred:
(Line: 63) MDB.AddSecondaryDrawerItem("Settings" ,Null ,
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
** Activity (main) Resume **
someone could be able to use this function: withHeaderBackgroundScaleType ?, I want to do is reduce the size of the header image without affecting the size of the header itself
I am using this great lib, but when the drawer is first displayed, the top item in the menu is dimmed as if it is selected. If I click on another line, then the clicked line will become dim and the first line gets "unselected".
So, I have two questions:
1) How can I prevent the top/first line from being highlighted when the drawer is first displayed?
2) How can I prevent a line from staying highlighted after the user removes their finger?
UPDATE: Figured it out, I had to do this to clear all selected lines:
I'm run with set to point to android-24 and I get this error:
Error:
c:\materialdrawer-develop\library\src\main\res\values\styles.xml:21: error: Error retrieving parent for item: No resource found that matches the given name 'MaterialTheme'.
I dont think this library is compatible with the newest Google system using the new maven repositories. you can try to edit the library´s xml-file and update the DependsOn directives to use the new maven repos
I dont think this library is compatible with the newest Google system using the new maven repositories. you can try to edit the library´s xml-file and update the DependsOn directives to use the new maven repos
This is a port of library from here: https://github.com/mikepenz/MaterialDrawer
Its an amazing library by Mike Penz and it simplifies most of the Navigation Drawer setup and theming.
Library Setup
1. Copy the MSMaterialDrawer.jar and xml files to your AdditionalLibs folder.
2. This is also dependent on AppCompat v7 Support library, so copy that to AdditionalLibs or use AdditionalJar.
3. Make sure your android.jar in B4A > ConfigurePaths is set to point to android-22 at least.
4. There are 3 resource zip files. Unzip them in your desired area, and use #AdditionalRes to point to them.
5. If you want to use your own theme in styles.xml, you can also point to that with #AdditionalRes.
6. Depending on how you want to use it, (for e.g. with AppCompat Toolbar) you can set #Extends: with extending to ActionbarActivity. You can also specify the theme in the manifest.
7. If you want to use Iconics (Icon fonts), you also need to copy the font files in your files directory in a folder called fonts/ (lowercase).
Library Usage
Creating a simple drawer
Making a simple drawer is amazingly easy. There are two drawer objects:
- MaterialDrawerBuilder: Used to set all the params and build the drawer
- MaterialDrawer: This is the result when you build the drawer from the MaterialDrawerBuilder.
There are many other options like actionbar/toolbar/statusbar options. Customising the header/footer.
The theming and color can only be changed via styles.xml.
Events
The drawer can raise the following events:
- Closed
- Opened
- ItemClick
- ItemLongClick
In order to know which item was clicked/longclicked you need to assign them an 'identifier' when adding to the drawer, so you can check it later in the click event.
Theming the Drawer
The main way to customize the looks of the drawer is via a theme.
The theme is applied on the activity, and the drawer inherits its properties from that theme.
The library already comes with the following built-in themes that you can set. These built-in themes all depend on the AppCompat library and resources, so make sure you have those linked and copied as well.
To further theme, you can either inherit from one of these themes and override the colors.
You can also create your own custom style, but be sure to add the style attributes requires by the Material Drawer. An example is available for this.
Basically it allows you to use an Icon Font as a drawable.
What is the advantage of this?
- You cant tint/color the drawable by code which is insanely cool.
- They scale well, and you can set the size according to your needs.
- The ttf files are generally small enough, so you can pack a large number of icons into a manageable file.
Currently there is support for font-awesome and google-material-icons fonts. Others can be added (but missing some features).
How to use: You must copy the font ttf file in your projects Files/fonts/<fontname>
Here is a link to the fonts used in the project. Download fonts
Then in code:
B4X:
Dim s2 As MSIconicDrawable
s2.Initialize("gmd_help") 'Load a google material design icon
s2.Color = 0xffff4081 'Change the color of iconDim s3 As MSIconicDrawable
s3.Initialize("faw_google_wallet") 'Load a font awesome icon
s3.Color = 0xffff4081 'Change the icon color'List all icons available in a fontLog(s2.ListDrawables("gmd")) 'List Google material design iconsLog(s2.ListDrawables("faw")) 'List Font awesome icons'Use the Drawable as
button.Background = s2.Drawable
Download and licence
Before you download make sure you read every single line in the above posts!
You should not re-distribute any of these files unless compiled to apk.
The files are too big for the forum so need to be downloaded off a link. Download here Donate here
Greetings again, ..
Went through the Material Design 1-4 exercises with success
Now experimenting this MSMaterialDrawer lib
With this setting:
#AdditionalRes: ..\resource\appcompat, android-support-v7-appcompat
#AdditionalRes: ..\resource\lib
#AdditionalRes: ..\resource\app
I get the following error while compiling
Generating R file. Error
..\resource\appcompat\values\attrs.xml:123: error: Attribute "actionBarSize" already defined with incompatible format.
C:\usr\b4a\Samples\MSMaterialDrawer\Objects\bin\extra\res1\res\values\values.xml:111: Original attribute defined here.
..\resource\appcompat\values\attrs.xml:388: error: Attribute "navigationMode" already defined with incompatible format.
If I comment this line #AdditionalRes: ..\resource\appcompat, android-support-v7-appcompat, I can compile and run the app but the icons are not displayed in the app
Also, when I open the project, I get the following warnings :
File 'magnify.png' is not used (warning #15)
Library 'AppCompat' is not used (warning #32)
How can I remove the PrimaryDrawerItem by code??? I need to dynamically display different items on the app drawer. For example, at first, I have three items on the app drawer, but then my user delete one item from there, so How can I remove that item from the app drawer??? Please anyone?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.