How to make onclicklistener for new menu item in android
<p>I am adding a menu item for texts selection. normally it shows cut,copy,share, etc.. I added a one more item to this menu and named the item as "Mark". </p>

<p>For this I added the following code in my Activity.Java</p>

<pre><code>@Override
public void onActionModeStarted(ActionMode mode) {
    if (mActionMode == null) {
        mActionMode = mode;
        Menu menu = mode.getMenu(); 
        menu.add("Mark");
        mode.getMenuInflater().inflate(R.menu.main, menu);
    }
    super.onActionModeStarted(mode);
}
</code></pre>

<p>I am able to get my menu item while long press on texts.. Below is the screen, which reflects my menu item.</p>

<p><a href="https://i.stack.imgur.com/rgg97.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rgg97.png" alt="enter image description here"></a></p>

<p>For this menu item, I want to do something while select it. So, I used the following code.</p>

<pre><code>@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if( item.getTitle().equals("Mark")){
        System.out.println("MenuItem Mark clicked----");
        Log.d("MenuItem  clicked----", "Mark");          
    }
    return super.onOptionsItemSelected(item);
}
</code></pre>

<p>Here, I am not able to get the message "MenuItem Mark clicked----" or "MenuItem  clicked---- Mark" in my Logcat.</p>

<p>How may I do this? </p>

<h2>update</h2>

<p>Followed Elitz's answer, but still no luck. my Changes below</p>

<pre><code>@Override
public void onActionModeStarted(ActionMode mode) {
    if (mActionMode == null) {
        mActionMode = mode;
        Menu menu = mode.getMenu();  
        menu.add(0,1000,0,"Mark");
        mode.getMenuInflater().inflate(R.menu.main, menu);
    }
    super.onActionModeStarted(mode);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == 1000) {
         System.out.println("MenuItem Mark clicked----");
         Log.d("MenuItem  clicked----", "Mark");
    }         
    return super.onOptionsItemSelected(item);
}
</code></pre>

<p>Added updated answer and still no messages came in Logcat</p>

<pre><code>private ActionMode.Callback startActionMode = (new ActionMode.Callback() {

    @Override
    public boolean onPrepareActionMode(ActionMode mode, Menu yourMenu) {
        return false;
    }

    @Override
    public void onDestroyActionMode(ActionMode mode) {

    }       
    @Override
    public boolean onCreateActionMode(ActionMode mode, Menu yourMenu) {
        return false;
    }       
    @Override
    public boolean onActionItemClicked(ActionMode mode, MenuItem yourMenu) {
        Log.d("MenuItem  clicked----303", "Mark");
        if (yourMenu.getItemId() == R.attr.actionModeSelectAllDrawable) {
             System.out.println("MenuItem Mark clicked----305");
             Log.d("MenuItem  clicked----", "Mark");
        }         
        return true;
    }
});
</code></pre>

<h2>update2</h2>

<p>Followed Ankesh's answer also, </p>

<pre><code>@Override
public void onActionModeStarted(ActionMode mode) {
    if (mActionMode == null) {
        mActionMode = mode;
        Menu menu = mode.getMenu();  
        menu.add(R.id.privateText);
        mode.getMenuInflater().inflate(R.menu.main, menu);
    }
    super.onActionModeStarted(mode);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.privateText) {
         System.out.println("MenuItem Mark clicked----");
         Log.d("MenuItem  clicked----", "Mark");
    }         
    return super.onOptionsItemSelected(item);
}
</code></pre>

<p>Both attempt there is no logs available...</p>

<h2>Update3</h2>

<p>For test the other menu, I found id for selectAll menu item in R,java, and tried the following code,</p>

<pre><code>@Override
public boolean onOptionsItemSelected(MenuItem item) {           if (item.getItemId() == R.attr.actionModeSelectAllDrawable) {
         System.out.println("MenuItem All clicked----");
         Log.d("MenuItem  clicked----", "All");
    }         
    return super.onOptionsItemSelected(item);
}
</code></pre>

<p>this is also not showing the message in Logcat. Is this function is right one for menu items selection. or what else I am missing in this?</p>