Library import option wont show and when i import the library shows Unused import statement

Viewed 17

Hello im coding with java in android and i have this code:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
**setSupportActionBar(toolbar);
if(getSupportActionBar() != null){
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeAsUpEnabled(true);**
}

the code inside the ** requires this library to be imported but first the suggestion to import the libary wont show and when i import it myself it says Unused import statement

this is the import code:

import android.support.v7.app.AppCompatActivity;

the weird part is that the same method is been used in the same project but only in this class wont work.

I also tried to do this method but makes error when its on run time

AppCompatActivity app = new AppCompatActivity();
app.setSupportActionBar(toolbar); //error here when execute

Thanks in advance!

1 Answers

I fixed it the solution was add AppCompatActivity on

public class X extends AppCompatActivity ....
Related