在我的应用程序中,我得到了一个活动,顶部有一些动作栏,下面是列表视图.我想要做的是 - 用列表向上滚动它,所以它隐藏然后,当列表向下滚动时 - 它应该向下滚动列表,就像它刚好在屏幕上边框上.我该如何实现这一功能?
android scroll vertical-scrolling android-listview android-actionbar
呼叫
if (getSupportActionBar() != null)
getSupportActionBar().hide();
Run Code Online (Sandbox Code Playgroud)
要不就:
getActionBar()
Run Code Online (Sandbox Code Playgroud)
在android.support.v7.app.ActionBarActivity中,我得到了这样的异常:
...
java.lang.NullPointerException
at android.support.v7.app.ActionBarImplICS.hide(ActionBarImplICS.java:302)
at android.support.v7.app.ActionBarImplJB.hide(ActionBarImplJB.java:20)
...
Run Code Online (Sandbox Code Playgroud)
编辑: 它只是在活动有主题时发生:
<style name="MyTheme" parent="Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
注意:
getSupportActionBar()
Run Code Online (Sandbox Code Playgroud)
不要返回null
java android nullpointerexception android-support-library android-actionbar-compat