Android アプリケーションのアクション バーで [戻る] ボタンを有効にしましたが、これによりエラーがスローされます。
4.0以降のエミュレーターで実行したときのAndroidアプリ。
これは、描画可能な new_indicator.xml とスタイル シートを使用して作成できました。
私の活動のコード行。閲覧のために貼り付けます。
new_indicator.xml
<?xml version="1.0" encoding="UTF-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:left="0dp"
android:right="5dp">
<bitmap android:src="@drawable/back" />
</item>
</layer-list>
I would paste the block of my activity that as the error
actionBar = getSupportActionBar();
****actionBar.setDisplayHomeAsUpEnabled(true); //This line is the error Null pointer error ****
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setIcon(android.R.color.transparent);
super.onCreate(savedInstanceState);
setContentView(com.example.rhemamedicare.R.layout.homeactivity);
context = HomeActivity.this;
cd = new ConnectionDetector(context);
My style sheet is below
I believe there is some thing that I am missing in the style
<style name="Theme.Jcodestyle" parent="@style/Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarItemBackground">@drawable/selectable_background_jcodestyle</item>
<item name="popupMenuStyle">@style/PopupMenu.Jcodestyle</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Jcodestyle</item>
<item name="actionBarTabStyle">@style/ActionBarTabStyle.Jcodestyle</item>
<item name="actionDropDownStyle">@style/DropDownNav.Jcodestyle</item>
<item name="actionBarStyle">@style/ActionBar.Solid.Jcodestyle</item>
<item name="actionModeBackground">@drawable/cab_background_top_jcodestyle</item>
<item name="actionModeSplitBackground">@drawable/cab_background_bottom_jcodestyle</item>
<item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Jcodestyle</item>
<item name="android:windowTitleSize">35dip</item>
<item name="android:spinnerStyle">@style/holoSpinner</item>
<item name="homeAsUpIndicator">@drawable/new_indicator</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">@style/Theme.Jcodestyle.Widget</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="ActionBar.Solid.Jcodestyle" parent="@style/Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="background">@drawable/ab_solid_jcodestyle</item>
<item name="backgroundStacked">@drawable/ab_stacked_solid_jcodestyle</item>
<item name="backgroundSplit">@drawable/ab_bottom_solid_jcodestyle</item>
<item name="progressBarStyle">@style/ProgressBar.Jcodestyle</item>
</style>
<style name="ActionBar.Transparent.Jcodestyle" parent="@style/Widget.Sherlock.ActionBar">
<item name="background">@drawable/ab_transparent_jcodestyle</item>
<item name="progressBarStyle">@style/ProgressBar.Jcodestyle</item>
</style>
<style name="PopupMenu.Jcodestyle" parent="@style/Widget.Sherlock.ListPopupWindow">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_jcodestyle</item>
</style>
<style name="DropDownListView.Jcodestyle" parent="@style/Widget.Sherlock.ListView.DropDown">
<item name="android:listSelector">@drawable/selectable_background_jcodestyle</item>
</style>
<style name="ActionBarTabStyle.Jcodestyle" parent="@style/Widget.Sherlock.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_jcodestyle</item>
</style>
<style name="DropDownNav.Jcodestyle" parent="@style/Widget.Sherlock.Spinner.DropDown.ActionBar">
<item name="android:background">@drawable/spinner_background_ab_jcodestyle</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_jcodestyle</item>
<item name="android:dropDownSelector">@drawable/selectable_background_jcodestyle</item>
</style>
<style name="ProgressBar.Jcodestyle" parent="@style/Widget.Sherlock.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progress_horizontal_jcodestyle</item>
</style>
<style name="ActionButton.CloseMode.Jcodestyle" parent="@style/Widget.Sherlock.ActionButton.CloseMode">
<item name="android:background">@drawable/btn_cab_done_jcodestyle</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Jcodestyle.Widget" parent="@style/Theme.Sherlock">
<item name="popupMenuStyle">@style/PopupMenu.Jcodestyle</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Jcodestyle</item>
</style>