Hide TextView after some time in Android
try this...
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView tv=(TextView)findViewById(R.id.tv);
tv.setText("+0");
tv.postDelayed(new Runnable() {
public void run() {
tv.setVisibility(View.INVISIBLE);
}
}, 3000);
}
}
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);
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);
How about hiding your text view with some animation?
int delayMillis = 3000;
Handler handler = new Handler();
final View v = tvRQPoint; // your view
handler.postDelayed(new Runnable() {
@Override
public void run() {
TranslateAnimation animate = new TranslateAnimation(0,-view.getWidth(),0,0);
animate.setDuration(500);
animate.setFillAfter(true);
v.startAnimation(animate);
v.setVisibility(View.GONE);
}, delayMillis);