I am trying to create a custom Toolbar on my FragmentActivity , but at the time when I launch the application, it crashes in this strip:
setSupportActionBar(toolbar);
I have no more code since I started adding this Toolbar , so I have this on my MainActivity
import android.support.v4.app.FragmentActivity; import android.support.v7.widget.Toolbar; public class MainActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);
My Toolbar Code:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:iosched="http://schemas.android.com/apk/res-auto" style="@style/HeaderBar" iosched:theme="@style/ActionBarThemeOverlay" iosched:popupTheme="@style/ActionBarPopupThemeOverlay" android:id="@+id/toolbar_actionbar" iosched:titleTextAppearance="@style/ActionBar.TitleText" iosched:contentInsetStart="?actionBarInsetStart" android:layout_width="match_parent" android:layout_height="?actionBarSize" />
What am I doing wrong?
user5486846
source share