I use the toolbar as my action in action. I am trying to add the getActionBar().setDisplayHomeAsUpEnabled(true); method getActionBar().setDisplayHomeAsUpEnabled(true); to the Activity.java file to navigate up for older devices.
In Android Studio, the following error message appears:
A method call may throw java.lang.NullPointerException
Navigating up on the toolbar works great on new devices ... now I'm trying to figure out how to make sure that it works for older devices. Please inform.
From build.gradle:
dependencies { compile "com.android.support:appcompat-v7:22.1.0" }
From AndroidManifest.xml:
android:theme="@style/Theme.AppCompat.NoActionBar.FullScreen"
From styles.xml
<style name="Theme.AppCompat.NoActionBar.FullScreen" parent="AppTheme"> <item name="android:windowNoTitle">true</item> <item name="windowActionBar">false</item> <item name="android:windowFullscreen">true</item>
from Activity.java
public class CardViewActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.cardviewinput); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) {
android android-actionbar toolbar
AJW Apr 22 '15 at 1:14 2015-04-22 01:14
source share