application use actionbarsherlock, ma l'attività principale ottiene getsupportactionbar restituisce null. AndroidManifest.xml:actionbarsherlock getSupportActionBar() restituisce null in android4.0, ma in 2.3.3 è ok
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Light1Theme" >
<activity
android:name=".activity.LogonActivity"
android:configChanges="orientation|keyboardHidden"
android:windowSoftInputMode="adjustUnspecified|stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
themes.xml:
<style name="Light1Theme" parent="Theme.Sherlock.Light">
LogonActivity.ava
extends SherlockActivity implements OnSharedPreferenceChangeListener {
...
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.logon);
try{
final ActionBar ab = getSupportActionBar();
//return null
ab.setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_bg_black));
getSupportActionBar().setIcon(R.drawable.hospital);
}catch(Exception e){
Log.e("", e.getMessage());
}