findViewById returns null when searching for elements in the actionbar on android 3.2
actionbarsherlock, android, android-actionbar
Solution
I dont know if this would help you, but from here:
Try adding:
<item name="customNavigationLayout">@layout/custom_action</item>
to go along with:
<item name="android:customNavigationLayout">@layout/custom_action</item>
Problem
I am working on an app which uses a custom actionbar layout, which is referenced via `android:actionBarStyle` and `android:customNavigationLayout` in the `themes.xml`. There are some elements in the bar, like a reload and some info button. On `android 4` devices those buttons can be found via `findViewById` (inside the activity), but on `android 3.2` `findViewById` returns null. This throws a NullPointerException then. The app is using ActionbarSherlock 4.2.0 Here is the themes.xml: ``` <style name="Theme.SRF.Tablet" parent="style/Theme.Sherlock"> <item name="android:windowContentOverlay">@drawable/header_shadow</item> <item name="android:actionBarStyle">@style/TTTActionBar</item> </style> <style name="TTTActionBar" parent="style/Widget.Sherlock.ActionBar"> <item name="android:background">@drawable/bg_header</item> <item name="android:customNavigationLayout">@layout/actionbar_custom</item> </style> ``` Activity: ``` @Override protected void onCreate(Bundle _savedInstanceState) { setContentView(...); // next line throws NullPointerException on android 3.2 findViewById(R.id.actionbar_custom_bt_refresh).setOnClickListener(mClickListener); .... } ```