Skip to content Skip to sidebar Skip to footer

How Can I Make Textview Invisible After One Click

I would like to know how to make multiple texView invisible when clicked on it won't be shown at all using only one onclick listener.

Solution 1:

you can make multiple TextView

<TextViewandroid:onClick="onInvisible"xx...
 />` 

in the xml.

Solution 2:

Check this

final List<TextView> textViewsToHide = Arrays.asList(
            findViewById(R.id.tvFirst),
            findViewById(R.id.tvSecond),
            findViewById(R.id.tvThird),
            .....
    );

    final View.OnClickListenertextViewOnClickListener= view -> {
        for (TextView textView : textViewsToHide) {
            textView.setVisibility(View.GONE);
        }
    };

    for (TextView textView : textViewsToHide) {
        textView.setOnClickListener(textViewOnClickListener);
    }

Post a Comment for "How Can I Make Textview Invisible After One Click"