Ich habe mehrere Schaltflächen in einem Layout dynamisch erstellt. Nun, wie kann ich dieses Layout nach der Verwendung entfernen.
zum Beispiel: -Wie kann ich Layout in Android entfernen?
LinearLayout parent = new LinearLayout(this);
parent.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
parent.setOrientation(LinearLayout.HORIZONTAL);
for (int i = 0; i < 10; i++) {
Button b = new Button(this);
b.setText("Primary");
Drawable image = ContextCompat.getDrawable(
getApplicationContext(),
R.drawable.your_image);
image.setBounds(0, 0, 60, 60);
b.setCompoundDrawables(null, null, image, null);
parent.addView(b);
}
Bitte beachten Sie eine der folgenden Antworten zu akzeptieren, wenn es Ihre Anfrage erfüllt – Lino