Skip to content

Instantly share code, notes, and snippets.

@ikew0ng
Last active December 11, 2015 18:19
Show Gist options
  • Save ikew0ng/4640684 to your computer and use it in GitHub Desktop.
Save ikew0ng/4640684 to your computer and use it in GitHub Desktop.
反射禁用Smartbar的方法,注意必须开启actionbar才有效
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