我正在使用此库作为滑动菜单:https://github.com/jfeinstein10/SlidingMenu。如何在Sherlockactionbar中设置可点击图标?
这是我的代码:
public class MainActivity extends SherlockActivity {
private com.actionbarsherlock.app.ActionBar action;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SlidingMenu sm = new SlidingMenu(this);
sm.setMode(SlidingMenu.LEFT);
sm.setShadowWidthRes(R.dimen.shadow_width);
sm.setShadowDrawable(R.drawable.shadow);
sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
sm.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
sm.setFadeDegree(0.35f);
sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
action = getSupportActionBar();
action.setDisplayHomeAsUpEnabled(true);
action.setDisplayShowHomeEnabled(false);
action.setHomeButtonEnabled(true);
action.setIcon(R.drawable.menu);
}
}
答案 0 :(得分:0)
您可以设置onClick侦听器。
sm.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});