我有一个扩展的活动ActionBar
,并且对如何设置setDisplayHomeAsUpEnabled(true)
.
我很困惑,因为我扩展了 actionbar 我不应该ActionBar
在扩展的类中创建一个对象ActionBar
。
package com.example.beerportfoliopro;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.beerportfolio.beerportfoliopro.R;
import static android.widget.Toast.*;
public class Discover extends ActionbarMenu {
//get beer details from bundle
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.activity_discover);
}
public void openTopBeers(View v){
Intent i = new Intent(this, Discover.class);
i.setClass(this, BPTopBeers.class);
startActivity(i);
}
public void openTopTastes(View v){
Intent i = new Intent(this, Discover.class);
i.setClass(this, BPTopTastes.class);
startActivity(i);
}
public void openTopBreweries(View v){
Intent i = new Intent(this, Discover.class);
i.setClass(this, BPTopBreweries.class);
startActivity(i);
}
public void openTopStyles(View v){
Intent i = new Intent(this, Discover.class);
i.setClass(this, BPTopStyles.class);
startActivity(i);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main2, menu);
return true;
}
}