Pass Button that Triggered ContextMenu
<p>So I am new to android programming and learning as I go. I am currently developing a soundboard that allows users to set a sound as a ringtone or notification. I have gotten the context menu set up successfully and I am able to differentiate between what the user clicks within the contextmenu. My only problem is I can't figure out how to tell which button triggered the contextmenu. Can anybody help?</p>

<p>Thanks
Justin</p>

<p>Edit: I was able to find a solution. Here is how I did it:</p>

<pre><code>@Override
    public void onCreateContextMenu(ContextMenu menu, View v,
                                    ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.options_menu, menu);
        lastButton = (Button) v;
    }

 @Override
    public boolean onContextItemSelected(MenuItem item) {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

        switch (item.getItemId()) {
            case R.id.Ringtone:
                if(lastButton == SoundButton)
                Toast.makeText(getApplicationContext(), "Ringtone soundbutton selected", Toast.LENGTH_SHORT).show();
                return true;
            case R.id.Notification:
                if(lastButton == SoundButtonButton){
                    Toast.makeText(getApplicationContext(), "Notification soundbutton set", Toast.LENGTH_SHORT).show();
                }

                return true;
            default:
                return super.onContextItemSelected(item);
        }
    }
</code></pre>
