setsupportactionbar() throws error
Solution 1
Edit:
Recently ActionBarActivity
has been deprecated in favor of ActionBarCompat
. You should use the new one, and use as the ActionBarCompat
themes, E.g. Theme.AppCompat.Light
you class has to extend ActionBarActivity
instead of Activity
, in order to use the method setSupportActionBar
Solution 2
Delete:
import android.widget.Toolbar;
Add:
import android.support.v7.widget.Toolbar;
Solution 3
ActionBarActivity is now deprecated. Use AppCompatActivity instead
Solution 4
You must extend your class from ActionBarActivity
from support package.
Liggliluff
I'm just your run of the mill citizen of Stockholm, Sweden. Programming isn't part of my job, but I do that as for fun. I've tried all different languages such as C++, Java, HTML, CSS, JavaScript Contact: [email protected]
Updated on June 04, 2022Comments
-
Liggliluff almost 2 years
I tried following the steps for displaying a drawer above the action bar but below the status bar. The steps found here: display over the ActionBar/Toolbar and under the status bar?
But after implementing the code, the following error was thrown:
error: cannot find symbol method setSupportActionBar(Toolbar)
I've searched on Google for this exact error and not a single result.I'm using Android Studio (1.1) and have tried using "Clean Build"
I'm usingimport android.support.v7.widget.Toolbar;
Toolbar toolbar = (Toolbar) findViewById(R.id.actionbar); setSupportActionBar(toolbar); //error
Hopefully, someone recognizes this error and has a quick answer for it - otherwise I can provide more information if requested.