When creating an imageView and TextView via code how to remove via code?

0

Well, create it that way

 TextView textView = new TextView(this);
textView.setText("Alguma coisa");
LinearLayout linear = (LinearLayout)findViewById(R.id.layoutVertical);
linear.addView(textView);

and to remove I did so

linear.removeView(textView);

But did not remove it, what other way to remove it?

    
asked by anonymous 05.03.2016 / 17:20

1 answer

1

In this case, use the setVisibility method of the TextView class, passing as View.GONE parameter, so the element will not be visible, nor will it take up space in LinearLayout.

textView.setVisibility(View.GONE);
    
08.03.2016 / 00:32