-1

getSupportActionBar() is giving error because class not extended from ActionBarActivity / AppCompatActivity .

I have tried with getActionBar() but not working .

Is it possible to get Action Bar without extending ActionBarActivity / AppCompatActivity ?

My code :- Here is my Class

public class MainActivity extends BaseActivity implements CallBackListener {

And here is the code where i need to use getSupportActionBar() method , but it is giving error :-

getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getSupportActionBar().getCustomView().findViewById(R.id.menu_icon)
            .setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    toggle();
                }
            });

1 Answers1

0

The simple answer to your question is NO .

Simply because the getActionBar() and getSupportActionBar() are part of AppCompatActivity and earlier classes. Do have a look at the Developer reference to understand better.

OBX
  • 6,044
  • 7
  • 33
  • 77