Activity does not display action bar

I joined Android Studio and Android App project a few weeks ago and I am trying to create a simple app with ActionBar options.

When I start Android Studio following Android Dev. Learning, I always meet this rendering error:

Android Studio not found. android.support.v7.app.ActionBarActivity (ecc ...)

I solved this error by installing a different theme. But whenever I try a new project, I will do it over and over again. First question: is there a way to fix this rendering issue? I meet this issue also in MainActivity.java where the extends ActionBarActivity is removed with a string telling me it is deprecated and advising me to use AppCompatActivity. Should I follow this advice?

Question number two: I read like 100 posts about guys who can't show an action in action and I've tried everything, but when I link an action menu to an activity via:

public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

      

I still cannot view the menu I created in the action bar. Some images may help me explain my problem better:

http://i.stack.imgur.com/5nPFx.png

And there is a layout for my activity:

http://i58.tinypic.com/oau8ed.png

As you can see, the icon button that I added is missing and no setting button such as menu display is displayed.

+3


source to share


1 answer


ActionBarActivity

it is now not recommended to use AppCompatActivity

to avoid this error:

Android Studio not found. android.support.v7.app.ActionBarActivity



you need to download the latest Support Library! and then you can use

import android.support.v7.app.AppCompatActivity

    public class MainActivity extends AppCompatActivity{
    ...
    ...
    ...

      

+2


source







All Articles