Maddie_J February 2016

cannot resolve method getSupportActionBar().setDisplayHomeAsUpEnabled(true);

I am using Android Studios, however, I am unable to add the below two methods as it says that it cannot resolve them.

 getSupportActionBar().setDisplayHomeAsUpEnabled(true);

  getSupportActionBar().setTitle("Detail")

;

Answers


Igor Monochkov February 2016

Try this in onCreate() method:

getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setTitle("Detail");


Gabriele Mariotti February 2016

Your issue is that you are not extending the AppCompatActivity:

Change:

 public class First extends FragmentActivity

with:

 public class First extends AppCompatActivity

As you can check in the doc the getSupportActionBar() method depends on the AppCompatActivity.

Post Status

Asked in February 2016
Viewed 2,533 times
Voted 7
Answered 2 times

Search




Leave an answer