如何使textview显示和消失?

时间:2017-01-06 03:40:26

标签: java android xml

默认值消失。我想知道如何使text-view出现并消失。

3 个答案:

答案 0 :(得分:5)

您可以设置特定的View's可见性赞:

yourTextViewName.setVisibility(View.VISIBLE) // For Visible/Appear

yourTextViewName.setVisibility(View.INVISIBLE)  // For Invisible/Disappear

yourTextViewName.setVisibility(View.GONE)   // For Gone / View not takes any space at Run time

希望这会有所帮助。(:

答案 1 :(得分:2)

这是您正在寻找的方法;

private void makeTextViewDisappear(){
    yourTV.setVisibility(View.VISIBLE);
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            yourTV.setVisibility(View.INVISIBLE);
            // OR yourTV.setVisibility(View.GONE) to reclaim the space used by textview
        }
    }, 10000); //for 10 seconds
}

如果这样有效,请不要忘记将此标记为正确答案。问候。

答案 2 :(得分:1)

new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                   yourTextViewName.setVisibility(View.VISIBLE)
                }
            }, 5000); <--- change time here