我已经开始使用android编程,并且正在尝试做:
对于最后一部分,问题是我有一个TextView
默认隐藏的可见性。我想让它可见几秒钟,然后使其消失。
这篇文章和这篇文章有所帮助,但他们实际上是在尝试相反的做法。
我的代码如下:
submitButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Check the validity of the user name.
if (valid) {
// Let the user log in.
} else {
// Make TextView visible for a few seconds.
}
}
});
我该怎么办?
在您的情况下,首先需要显示TextView然后再进行显示INVISIBLE
。
使用textView.postDelayed方法如下:
if(valid){ //let the user login }
else
{
// make TextView visible here
textView.setVisibility(View.VISIBLE);
//use postDelayed to hide TextView
textView.postDelayed(new Runnable() {
public void run() {
textView.setVisibility(View.INVISIBLE);
}
}, 3000);
//how to make the textview visible for a few seconds
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句