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")
;
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.