How can I make textView invisible after one click

拈花ヽ惹草 提交于 2019-12-13 08:25:56

问题


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.


回答1:


you can make multiple TextView

<TextView
 android:onClick="onInvisible"    
 xx...
 />` 

in the xml.




回答2:


Check this

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

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

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


来源:https://stackoverflow.com/questions/48434047/how-can-i-make-textview-invisible-after-one-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!