Мое приложение падает каждый раз с ошибкой в java.lang.RuntimeException: Unable to start activity ComponentInfo{sidssol.com.bit_taxi_b2c/sidssol.com.bit_taxi_b2c.Home}: java.lang.NullPointerException
для getActionBar(). SetDisplayHomeAsUpEnabled (правда), вставили все необходимые code.Can кто проверить этот кодgetsupportActionBar(). SetDisplayHomeAsUpEnabled (истина) .setDisplayHomeAsUpEnabled (истина) бросает NullPointerException
public class Home extends ActionBarActivity {
adapter = new NavDrawerListAdapter(getApplicationContext(),
navDrawerItems);
mDrawerList.setAdapter(adapter);
// enabling action bar app icon and behaving it as toggle button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.ic_drawer, //nav menu toggle icon
R.string.app_name, // nav drawer open - description for accessibility
R.string.app_name // nav drawer close - description for accessibility
)
}
Style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar" >
<item name="android:windowTranslucentStatus">true</item>
</style>
<style name="Theme.Test" parent="@style/Theme.AppCompat.Light">
<!-- customize the color palette -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="drawerArrowStyle">@style/Theme.Test.DrawerArrowStyle</item>
</style>
<style name="Theme.Test.DrawerArrowStyle" parent="@style/Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@android:color/white</item>
</style>
<style name="Divider">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item>
<item name="android:background">?android:attr/listDivider</item>
</style>
</resources>
Androidmainfest.xml
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".loginForm"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
В дополнение к тому, чтобы дать им рыбу, научите их также рыбалке ... – Melquiades
Все еще имея такую же проблему. –