keklikhasan / ldrawer Goto Github PK
View Code? Open in Web Editor NEWAndroid drawer icon with material design animation
License: Apache License 2.0
Android drawer icon with material design animation
License: Apache License 2.0
When the drawer is open and you press back instead of closing it does what's in the onbackpressed method. Any solution
I can't get actionBar when i use <style name="AppTheme" parent="Theme.AppCompat.Light">, but there is nothing when i use Theme.Holo.Light.DarkActionBar...
NoSuchMethodException: setHomeActionContentDescription [int]
at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getDeclaredMethod(Class.java:685)
at com.ikimuhendis.ldrawer.ActionBarDrawerToggle.setActionBarDescription(ActionBarDrawerToggle.java:161)
at com.ikimuhendis.ldrawer.ActionBarDrawerToggle.syncState(ActionBarDrawerToggle.java:58)
at com.fongmi.ticket.activity.Main.onPostCreate(Main.java:158)
at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1145)
at com.lbe.security.service.core.client.b.x.callActivityOnPostCreate(Unknown Source)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2329)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2398)
at android.app.ActivityThread.access$600(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5356)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:133)
at dalvik.system.NativeStart.main(Native Method)
AppCompat's ActionBarDrawerToggle class provides drawable and the rotating animation.
As the title says is this library possible for use with eclipse? I'm still new to android development and android studio still takes some getting use to. Thanks in advance!
Edit- Nvm
It just shows the arrow, no hamburger icon. Using Theme.AppCompat.
Hi, first of all thanks for your work!
I have only a question: is there a way to add subcategory to the menu?
Thanks
This works fine but can't show my overflow button
Just don't work, the drawer icon is static with arrow icon.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "my.app.package"
minSdkVersion 9
targetSdkVersion 21
versionCode 11
versionName "2.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.ikimuhendis:ldrawer:0.1'
}
Hi,
When I add the this dependence to my project I get a Manifest compatibility problem, what should I do to solve it?
The compiler tells me to user tools:overrideLibrary="com.ikimuhendis.ldrawer" to solve it. It's recommended?
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library /Users/idemax/Development/Workspaces/NGTProjects/nnotes/APP/v2/app/build/intermediates/exploded-aar/com.ikimuhendis/ldrawer/0.1/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.ikimuhendis.ldrawer" to force usage
I am using getSupportActionBar() method in my ActionBarActivity and getting the following error. Is there anything I can do to make it work?. If I change the code in the library from getActionBar() to getSupportActionBar() will it solve my problem?
E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle( 1943): java.lang.NullPointerException: expected receiver of type android.app.ActionBar, but got null
E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle( 1943): at java.lang.reflect.Method.invokeNative(Native Method)
E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle( 1943): at java.lang.reflect.Method.invoke(Method.java:515)
E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle( 1943): at com.ikimuhendis.ldrawer.ActionBarDrawerToggle.setActionBarUpIndicator(ActionBarDrawerToggle.java:130)
E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle( 1943): at com.ikimuhendis.ldrawer.ActionBarDrawerToggle.syncState(ActionBarDrawerToggle.java:57)
E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle( 1943): at com.filemanager.android.FazoolClass.onPostCreate(FazoolClass.java:171)
E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle( 1943): at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1150)
E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle( 1943): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2167)
E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle( 1943): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle( 1943): at android.app.ActivityThread.access$800(ActivityThread.java:135)
E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle( 1943): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle( 1943): at android.os.Handler.dispatchMessage(Handler.java:102)
E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle( 1943): at android.os.Looper.loop(Looper.java:136)
代码运行时,出现 java.lang.NoSuchMethodException: setHomeAsUpIndicator [class android.graphics.drawable.Drawable] 错误 ,请我这是什么原因啊
hi house
please i need help on this issue in my android build.
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library [com.android.support:design:26.0.0-alpha1] C:\Users\klightoftheworld.android\build-cache\076d9e56e1088709047f81c5062558fc68ba759f\output\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.design" to force usage
Error:Gradle: A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.ikimuhendis:ldrawer:1.0.
Required by:
test:app:unspecified
Merhabalar,
Android'in native navigation drawer'ını kullanıyorum. DrawerArrowDrawable.java'yı projeme ekledim. "You can use like using normal drawer, instead of using" kısmını uyguladım.
mDrawerToggle.setAnimateEnabled(true); olarak ekledim. Animasyon çalışmıyor? Eksik bir şey mi yapıyorum?
----- MANIFEST----
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-sdk android:targetSdkVersion="25" android:minSdkVersion="23"
tools:overrideLibrary="com.google.firebase.auth.api,com.google.android.gms.games" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<!-- REQUIRED for wifi wake functionality -->
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<uses-feature android:required="true" android:glEsVersion="0x00020000"/>
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="false" android:anyDensity="true"/>
<application android:name="com.saas.classes.ApplicationInit" android:theme="@style/AppTheme" android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:debuggable="true">
<uses-library android:name="com.google.android.maps" android:required="true"> </uses-library>
<!-- Start the Service if applicable on boot -->
-<receiver android:name=".services.ServiceStarter">
-<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<receiver android:name=".classes.OnAlarmReceiver"> </receiver>
<receiver android:name=".classes.UAPushNotification"> </receiver>
<service android:name=".classes.AlarmService"> </service>
<activity android:name=".classes.SplashActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".classes.HomeActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name=".utilities.ActivityCustom" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.DialogActivity" android:theme="@style/AlertDialogCustom" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.DialogDateActivity" android:theme="@style/AlertDialogCustom" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.DialogHourActivity" android:theme="@style/AlertDialogCustom" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.EmergencyActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.LocationFilterActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.SearchProductsActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.SearchProductsDispActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name="com.saas.classes.PopupQuantityActivity" android:theme="@style/AlertPopup" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name="com.saas.classes.PopupOrderActivity" android:theme="@style/AlertPopup" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name="com.saas.classes.SettingsActivity" android:theme="@style/AlertSettings" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name="com.saas.classes.ShareActivity" android:theme="@style/AlertSettings" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name="com.saas.classes.ProfileActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
</activity>
<activity android:name="com.saas.classes.ProfileViewActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name="com.saas.classes.PopUp" android:theme="@style/AlertPopup" android:screenOrientation="portrait"> </activity>
<activity android:name="com.saas.classes.PopUpSmall" android:theme="@style/AlertPopup" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.FavoritesActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.PharmacyActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.PharmacyDetailActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.PharmacyDetailMapActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.RecordatorioAddActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.RecordatorioCalendarActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.TratamientosMainActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.TratamientoAddActivity" android:windowSoftInputMode="stateAlwaysHidden|adjustPan" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.TratamientoMedicamentoAddActivity" android:windowSoftInputMode="stateAlwaysHidden|adjustPan" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.TratamientoMedicamentoDetailActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.OfertasMainActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.OfertasCatalogActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.SearchPharmacyActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.PharmacyJornadaDetailActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.JornadasCalendarActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.WebLoaderActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name=".services.Notifications" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"> </activity>
<activity android:name=".classes.TutorialHomeActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.TutorialMenuActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.TutorialJornadasActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.TutorialBusquedaActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.TutorialTratamientosAActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<activity android:name=".classes.TutorialTratamientosBActivity" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity>
<!-- <activity android:name="com.saas.PushPreferencesActivity" /> <activity android:name="com.saas.LocationActivity" /> -->
<!-- android:value="AIzaSyCIPLuLnAlku0BO4W7aJkUF1hZLm6WhCAQ" android:value="AIzaSyD62Uh2uL8QCFjpzw8jhj0Yd97uFyOjcyo"-->
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyCRTYFiFvO7_My8v50_T8sShF1s5gyEmbU"/>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
</application>
--------BUILD GRADLE-------
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
apply plugin: 'android'
dependencies {
compile files('../../../../SAAS/libs/jackson-annotations-2.1.0.jar')
compile files('../../../../SAAS/libs/jackson-core-2.1.0.jar')
compile files('../../../../SAAS/libs/jackson-databind-2.1.0.jar')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.android.gms:play-services:11.0.0'
}
android {
compileSdkVersion 24
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 23
targetSdkVersion 25
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
productFlavors {
}
}
I recently converted my activities to AppCompatActivty,
And therefor converted to getSupportActionBar().
Since then my drawer never shows the hamburger, It only has the back button? All other functionality is still good.
here is my activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
//---------------------NAV DRAWER STARTS
ActionBar ab = getSupportActionBar();
ab.setDisplayHomeAsUpEnabled(true);
ab.setHomeButtonEnabled(true);
ab.setTitle("Dashbaord");
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
DrawerArrowDrawable drawerArrow = new DrawerArrowDrawable(this) {
@Override
public boolean isLayoutRtl() {
return false;
}
What am I missing?
};
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, drawerArrow, R.string.drawer_open, R.string.drawer_close) {
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
invalidateOptionsMenu();
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();
//-------------------------------DRAWER ENDS
}
I do this library with Android 2.3.3 and SupportActionbar v7 . it show only <-- in homebutton not show = and animation like the sample. I soll make.
Hi,
I have i little problem, I can't able to show the humburger icon, there is always arrow icon and the animation doesn't work. Where is the setting about humburger icon and what control the animation?
Thanks a lot.
Francesco.
The navDrawer should be over the action bar in material design.
Add support to ActionBarActivity and AppcompatActivity.
Use the code below to replace the default ActionBarDrawerToggle class.
Help this will help all of you.
package com.ikimuhendis.ldrawer;
import android.app.ActionBar;
import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import java.lang.reflect.Method;
public class ActionBarDrawerToggle extends android.support.v4.app.ActionBarDrawerToggle {
private static final String TAG = ActionBarDrawerToggle.class.getName();
protected Activity mActivity;
protected DrawerLayout mDrawerLayout;
protected int mOpenDrawerContentDescRes;
protected int mCloseDrawerContentDescRes;
protected DrawerArrowDrawable mDrawerImage;
protected boolean animateEnabled;
public ActionBarDrawerToggle(Activity activity, DrawerLayout drawerLayout, int drawerImageRes, int openDrawerContentDescRes, int closeDrawerContentDescRes) {
super(activity, drawerLayout, drawerImageRes, openDrawerContentDescRes, closeDrawerContentDescRes);
}
public ActionBarDrawerToggle(Activity activity, DrawerLayout drawerLayout, DrawerArrowDrawable drawerImage, int openDrawerContentDescRes, int closeDrawerContentDescRes) {
super(activity, drawerLayout, R.drawable.ldrawer_ic_drawer, openDrawerContentDescRes, closeDrawerContentDescRes);
mActivity = activity;
mDrawerLayout = drawerLayout;
mOpenDrawerContentDescRes = openDrawerContentDescRes;
mCloseDrawerContentDescRes = closeDrawerContentDescRes;
mDrawerImage = drawerImage;
animateEnabled = true;
}
public void syncState() {
if (mDrawerImage == null) {
super.syncState();
return;
}
if (animateEnabled) {
if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
mDrawerImage.setProgress(1.f);
} else {
mDrawerImage.setProgress(0.f);
}
}
setActionBarUpIndicator();
setActionBarDescription();
}
public void setDrawerIndicatorEnabled(boolean enable) {
if (mDrawerImage == null) {
super.setDrawerIndicatorEnabled(enable);
return;
}
setActionBarUpIndicator();
setActionBarDescription();
}
public boolean isDrawerIndicatorEnabled() {
if (mDrawerImage == null) {
return super.isDrawerIndicatorEnabled();
}
return true;
}
public void onConfigurationChanged(Configuration newConfig) {
if (mDrawerImage == null) {
super.onConfigurationChanged(newConfig);
return;
}
syncState();
}
public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
if (mDrawerImage == null) {
super.onDrawerSlide(drawerView, slideOffset);
return;
}
if (animateEnabled) {
mDrawerImage.setVerticalMirror(!mDrawerLayout.isDrawerOpen(GravityCompat.START));
mDrawerImage.setProgress(slideOffset);
}
}
@Override
public void onDrawerOpened(View drawerView) {
if (mDrawerImage == null) {
super.onDrawerOpened(drawerView);
return;
}
if (animateEnabled) {
mDrawerImage.setProgress(1.f);
}
setActionBarDescription();
}
@Override
public void onDrawerClosed(View drawerView) {
if (mDrawerImage == null) {
super.onDrawerClosed(drawerView);
return;
}
if (animateEnabled) {
mDrawerImage.setProgress(0.f);
}
setActionBarDescription();
}
protected void setActionBarUpIndicator() {
if (mActivity != null) {
try {
if(mActivity instanceof ActionBarActivity){
Method setHomeAsUpIndicator = android.support.v7.app.ActionBar.class.getDeclaredMethod("setHomeAsUpIndicator",
Drawable.class);
setHomeAsUpIndicator.invoke(getActionBar(), mDrawerImage);
}else{
Method setHomeAsUpIndicator = ActionBar.class.getDeclaredMethod("setHomeAsUpIndicator",
Drawable.class);
setHomeAsUpIndicator.invoke(getActionBar(), mDrawerImage);
}
return;
} catch (Exception e) {
Log.e(TAG, "setActionBarUpIndicator error", e);
}
final View home = mActivity.findViewById(android.R.id.home);
if (home == null) {
return;
}
final ViewGroup parent = (ViewGroup) home.getParent();
final int childCount = parent.getChildCount();
if (childCount != 2) {
return;
}
final View first = parent.getChildAt(0);
final View second = parent.getChildAt(1);
final View up = first.getId() == android.R.id.home ? second : first;
if (up instanceof ImageView) {
ImageView upV = (ImageView) up;
upV.setImageDrawable(mDrawerImage);
}
}
}
protected void setActionBarDescription() {
if (mActivity != null && getActionBar() != null) {
try {
if(mActivity instanceof ActionBarActivity){
Method setHomeActionContentDescription = android.support.v7.app.ActionBar.class.getDeclaredMethod(
"setHomeActionContentDescription", Integer.TYPE);
setHomeActionContentDescription.invoke(getActionBar(),
mDrawerLayout.isDrawerOpen(GravityCompat.START) ? mOpenDrawerContentDescRes : mCloseDrawerContentDescRes);
}else{
Method setHomeActionContentDescription = ActionBar.class.getDeclaredMethod(
"setHomeActionContentDescription", Integer.TYPE);
setHomeActionContentDescription.invoke(getActionBar(),
mDrawerLayout.isDrawerOpen(GravityCompat.START) ? mOpenDrawerContentDescRes : mCloseDrawerContentDescRes);
}
if (Build.VERSION.SDK_INT <= 19) {
if(mActivity instanceof ActionBarActivity){
ActionBarActivity actionBarActivity=(ActionBarActivity)mActivity;
actionBarActivity.getSupportActionBar().setSubtitle(actionBarActivity.getSupportActionBar().getSubtitle());
}else{
mActivity.getActionBar().setSubtitle(mActivity.getActionBar().getSubtitle());
}
}
} catch (Exception e) {
Log.e(TAG, "setActionBarUpIndicator", e);
}
}
}
private Object getActionBar(){
Object actionBar=null;
if(mActivity instanceof ActionBarActivity){
actionBar=((ActionBarActivity) mActivity).getSupportActionBar();
}else{
actionBar=mActivity.getActionBar();
}
return actionBar;
}
public void setAnimateEnabled(boolean enabled) {
this.animateEnabled = enabled;
}
public boolean isAnimateEnabled() {
return this.animateEnabled;
}
}
As far as I tested everything works, but when the Drawer is opened and closed such exception occurs:
10-23 20:09:38.992 1818-1818/<some_package> E/com.ikimuhendis.ldrawer.ActionBarDrawerToggle﹕ setActionBarUpIndicator
java.lang.NoSuchMethodException: setHomeActionContentDescription [int]
at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getDeclaredMethod(Class.java:685)
at com.ikimuhendis.ldrawer.ActionBarDrawerToggle.setActionBarDescription(ActionBarDrawerToggle.java:161)
at com.ikimuhendis.ldrawer.ActionBarDrawerToggle.onDrawerOpened(ActionBarDrawerToggle.java:110)
at ua.com.florin.anotherflashlight.MainActivity$2.onDrawerOpened(MainActivity.java:73)
at android.support.v4.widget.DrawerLayout.dispatchOnDrawerOpened(DrawerLayout.java:587)
at android.support.v4.widget.DrawerLayout.updateDrawerState(DrawerLayout.java:539)
at android.support.v4.widget.DrawerLayout$ViewDragCallback.onViewDragStateChanged(DrawerLayout.java:1495)
at android.support.v4.widget.ViewDragHelper.setDragState(ViewDragHelper.java:866)
at android.support.v4.widget.ViewDragHelper$2.run(ViewDragHelper.java:335)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
My Activity is ActionBarActivity and i change v4.ActionBarDrawerToggle to LDrawer's ActionBarDrawerToggle
but i got same error ActionBarDrawerToggle line 130 setHomeAsUpIndicator.invoke(mActivity.getActionBar(), mDrawerImage)
getActionBar is null
so i think LDrawer seems not support v7.ActionBarActivity ?!
in android.support.v7.app.AppCompatActivity, getActionBar() will report an error, it should be getSupportActionBar()
I am needing an image right beside the text of each item in the drawer. Is there an easy way to implement this before I starting going through the trouble of doing a custom list and all that?
If I use this library and the Theme : "Theme.AppCompat" it doesn't work, it's only my problem? :-/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.