onItemContextMenu and button created programatically problem
<p>I would like if anybody could help to solve the problem, that I'm trying to fix in my code. I'm really despearte!</p>

<p>I would like to know if it's possible get from the contextmenu, all the information of the button that I created, and use the setText function later.</p>

<p>Ok, first of all I create a tablerow with some buttons (like a soundboard application)</p>

<pre><code>for (int j = 0 ; index &gt; 0 &amp;&amp; j &lt; 2 ; j++) {
    final CustomToggleButton tagB = new CustomToggleButton(this);
    tagB.setId(index);
    ...
    ...
    registerForContextMenu(tagB);
    tagB.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
               ....
          }
          ...
    }
}
</code></pre>

<p>Secondly, I let every button an "edit" option for changing the text in it:</p>

<pre><code>@Override
 public void onCreateContextMenu(ContextMenu menu, View v,  ContextMenuInfo menuInfo) {
     AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo;
     menu.setHeaderTitle("Opciones de la etiqueta");
     menu.add(0, v.getId(), 0, "Edit");
 }
</code></pre>

<p>Finally I use onContextItemSelected for creating an EditText Alert and let the possibility of introduce the new text.</p>

<pre><code>@Override
public boolean onContextItemSelected(final MenuItem item) {
    if (item.getTitle() == "Edit") {
        AlertDialog.Builder alert = new AlertDialog.Builder(this);
        final EditText input = new EditText(this);
        alert.setView(input);
        alert.setTitle("Nombre del tag");
        alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                String value = input.getText().toString().trim();
                Log.v(null, "nombre del tag nuevo: "+value);
                Toast.makeText(getApplicationContext(), value,Toast.LENGTH_SHORT).show();
                int button_id = item.getItemId();   // BUTTON ID? 
                //CustomToggleButton tagB = (CustomToggleButton) findViewById(R.id.button_id);//DOESN'T WORK!!
                //CustomToggleButton tagB = (CustomToggleButton) findViewById(button_id); // NEITHER DOESN'T WORK!!
            }
        });
        alert.setNegativeButton("Cancel",new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                dialog.cancel();
            }
        });
        alert.show();
        return true;
    }
    else return super.onContextItemSelected(item);
}
</code></pre>

<p>The problem is that I can't use its id from R.java, because I have created the button programatically...</p>

<p>Is there any solution for this problem??</p>
