问题
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