I have this in action:
public class MainActivity extends AppCompatActivity implements FragmentDrawer.FragmentDrawerListener{ private Toolbar mToolbar; private FragmentDrawer drawerFragment; private RecyclerView recyclerView; private IsAdapter isAdapter; private List<Is> isList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayShowHomeEnabled(true); recyclerView = (RecyclerView) findViewById(R.id.recycler_view); isList = new ArrayList<>(); isAdapter = new IsAdapter(this, isList); RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(this, 1); recyclerView.setLayoutManager(mLayoutManager); recyclerView.addItemDecoration(new GridSpacingItemDecoration(2, dpToPx(10), true)); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setAdapter(isAdapter); drawerFragment = (FragmentDrawer) getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer); drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar); drawerFragment.setDrawerListener(this);
I use my own theme (which is material), it works well, then I made some changes to the code, now I get this error. How can i fix this? Thanks in advance.
My manifest file I have is: android:theme="@style/MyMaterialTheme">
I googled, solutions say change AppCompatActivity
to Activity
or FragmentActivity
. When I do this, I get an error in these lines:
setSupportActionBar(mToolbar); getSupportActionBar().setDisplayShowHomeEnabled(true);
Here are my styles.xml:
<resources> <style name="MyMaterialTheme" parent="MyMaterialTheme.Base"> </style> <style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="windowNoTitle">true</item> <item name="windowActionBar">false</item> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> </resources>
source share