Hide TextView after some time in Android

2020-07-06 02:36发布

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.

7条回答
做自己的国王
2楼-- · 2020-07-06 03:05

What you are trying to do is ok but after three seconds you want to hide the textview so use setVisibility

tvRQPoint.setText("+0");
    tvRQPoint.postDelayed(new Runnable() {
        public void run() {
            tvRQPoint.setVisibility(View.INVISIBLE);
        }
    }, 3000);
查看更多
登录 后发表回答