Im having some trouble with setting textview to invisible/visible.
basicly i want this to happen when an on/off button has been clicked.
what i did is kind of like
textview.setVisibility(TextView.VISIBLE);
textview.setVisibility(TextView.INVISIBLE);
when i try executing this the emultor says that the app has stopped unexcpetedly
In order to set the visibility of a view you call: button. setVisibility(View. GONE);
The easiest way to animate Visibility changes is use Transition API which available in support (androidx) package. Just call TransitionManager. beginDelayedTransition method then change visibility of the view. There are several default transitions like Fade , Slide .
null){ int lines = l. getLineCount(); if ( lines > 0) if ( l. getEllipsisCount(lines-1) > 0) Log. d(TAG, "Text is ellipsized"); } } });
Inside the onClick(View v) implementation add: v. getId(); To determine whice TextView pressed.
Are you building this from XML or programmatically?
I would make it with an XML file then when the Activity runs change the property. Be sure to use setContentView(R.layout.main);
before you try to get the TextView with findViewById(...)
.
Call .setVisibility(View.GONE);
on the TextView to hide it.
Call .setVisibility(View.VISIBLE);
to on the TextView to show it.
I have an example that does something like this. You can see the code here: https://github.com/ethankhall/Morse-Messenger/blob/master/src/com/kopysoft/MorseMessenger/Translate.java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With