Last active
December 11, 2015 18:19
-
-
Save ikew0ng/4640684 to your computer and use it in GitHub Desktop.
反射禁用Smartbar的方法,注意必须开启actionbar才有效
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.imid.fuubo.utils; | |
import android.annotation.SuppressLint; | |
import android.app.ActionBar; | |
import android.support.v4.app.FragmentActivity; | |
import java.lang.reflect.InvocationTargetException; | |
import java.lang.reflect.Method; | |
@SuppressLint("NewApi") | |
public class SmartBarUtils { | |
public static final void hide(FragmentActivity activity) { | |
ActionBar actionBar = activity.getActionBar(); | |
if (actionBar == null) { | |
return; | |
} | |
Class<? extends ActionBar> ActionBarClass = actionBar.getClass(); | |
Method setTabsShowAtBottom; | |
try { | |
setTabsShowAtBottom = ActionBarClass.getMethod("setTabsShowAtBottom", Boolean.TYPE); | |
setTabsShowAtBottom.invoke(activity.getActionBar(), true); | |
} catch (NoSuchMethodException e) { | |
e.printStackTrace(); | |
} catch (IllegalArgumentException e) { | |
e.printStackTrace(); | |
} catch (IllegalAccessException e) { | |
e.printStackTrace(); | |
} catch (InvocationTargetException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment