使用ActionBar,必须继承ActionBarActivity
ActionBar actionBar = getActionBar();
actionBar.setTitle("谷歌电子市场"); //设置标题
// actionBar.setIcon(R.drawable.bg_photo);
actionBar.setLogo(R.drawable.ic_theme); //设置logo
actionBar.setHomeButtonEnabled(true); //logo是否可以点击
// actionBar.setDisplayShowHomeEnabled(false);//隐藏logo
//actionBar.setDisplayHomeAsUpEnabled(true);//设置返回键
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Toast.makeText(this, "点击了...", Toast.LENGTH_LONG).show();
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}