Search code examples
androidtextview

Hide TextView after some time in Android


I want to hide TextView after some time interval say 3 seconds. I googled and found some code and I tried code as shown below but It is not working.

Please tell me what is the wrong with this ?

tvRQPoint.setText("+0");
tvRQPoint.postDelayed(new Runnable() {
    public void run() {
        tvRQPoint.setText("+0");
    }
}, 3000);

One more thing, how to remove timeout ? As I am using this on click event of ListView, If user clicks on one option and then clicks on second option, then as 3 seconds got over (after clicked on first option), It does not show second option for 3 seconds.


Solution

  • try View INVISIBLE or GONE like:

    tvRQPoint.postDelayed(new Runnable() {
    public void run() {
        tvRQPoint.setVisibility(View.INVISIBLE);
    }
    }, 3000);
    

    Set View visibility with view.setVisibility(View.INVISIBLE|View.VISIBLE|View.GONE);