How to show a view for 3 seconds, and then hide it?

后端 未结 4 642
北恋
北恋 2020-12-23 22:23

I tried with threads, but android throws \"CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.\".

So how can

4条回答
  •  半阙折子戏
    2020-12-23 22:55

    Without the need to have a reference to a view or sleep a thread:

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                // do stuff
            }
        }, 3000);
    

提交回复
热议问题