Wie kann ich Sie entfernen / löschen eines dynamisch erzeugten button in Android?

Also ich erzeugt einige button. Die zahlen, es hängt vom Benutzer ab (beim anklicken einer Schaltfläche erstellen Sie eine neue).

Dies ist, wie ich es gemacht:

   RelativeLayout layout = (RelativeLayout) findViewById(R.id.layoutcprompt);
    RelativeLayout.LayoutParams OBJ = new RelativeLayout.LayoutParams (140,80);
    if ((commandsi%6)==0) {adjust=adjust+86; commandsi=1;}
    OBJ.leftMargin =(140*(commandsi-1))+10;
    OBJ.topMargin =250+adjust;
    Button command = new Button(this);
    command.setLayoutParams(OBJ);
    command.setId(ID);
    command.setText(edittxt.getText().toString());
    edittxt.setText("");
    command.setBackgroundResource(R.drawable.costum_button);
    command.setTextColor(Color.WHITE);
    command.setTextSize(14);
    layout.addView(command);
    command.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Button b = (Button)view;
            scommand=b.getText().toString();
        }
    });
    command.setVisibility(View.VISIBLE);

Möchte ich entfernen/löschen, aber ich weiß nicht, wie.... Ich gab Ihnen eine eindeutige id, aber ich habe noch keine Ahnung, wie kann ich Sie entfernen/

InformationsquelleAutor prody | 2013-01-27
Schreibe einen Kommentar