Overriding onOptionsItemSelected from SherlockFragmentActivity

前端 未结 2 1152
南旧
南旧 2021-02-07 01:47

Yesterday, I found a great library that allowed me to have a \"facebook menu\" with a button on the top left of an action bar which, when pressed, would slide in a menu of items

2条回答
  •  [愿得一人]
    2021-02-07 02:08

    Turns out that when using ABS you will need to specify the namespace of MenuItem to make sure that you're overriding the correct method. My solution was as follows :

    @Override
    public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) 
    {
        int id = item.getItemId();
        Log.d("item ID : ", "onOptionsItemSelected Item ID" + id);
        if (id == android.R.id.home) {
            rbmView.toggleMenu();
    
            return true;
    
        } else {
            return super.onOptionsItemSelected(item);
        }
    }
    

提交回复
热议问题