I'm trying to replace the ActionBar of my app with a Toolbar but I can't because I can't use setSupportActionBar(). It says "setSupportActionBar() is undefined for the type MainActivity" even if MainActivity extends ActionBarActivity. I don't know what to do, any help? Do you need me to post my code?
EDIT: Now the code works but my app crashes on start and it says: "Attempt to invoke virtual method getTitle()". What do I miss?
EDIT2: Everything works I forgot I had a Fragment and because of that it gave me nullPointer
Now use :
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
setSupportActionBar(toolbar);
XML :
android.support.v7.widget.Toolbar
Extends :
public class MainActivity extends AppCompatActivity
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With