I cannot make Button invisible and TextView visible after clicking on the Button. Here is XML code
`<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AttentionActivity">
<Button
android:id="@+id/buttonIagree"
android:text="I AGREE" />
<TextView
android:id="@+id/wait"
android:text="@string/wait"
android:visibility="invisible" />`
and Java code
`Button button = findViewById(R.id.buttonIagree);
TextView wait = findViewById(R.id.wait);
button.setOnClickListener(v -> {
wait.setVisibility(View.VISIBLE);
button.setVisibility(View.GONE);
if (wait.getVisibility() == View.VISIBLE && button.getVisibility() == View.GONE) {
t.start();`
t starts without any problems and works fine, but the Button stays visible and TextView stays invisible. I've tried to put button and textview in global variables and in LinearLayout with the same result. What am I doing wrong?