In my layout, I have TextViews that are initially set to be invisible. When the user presses the start button, I want one of these TextViews to be visible for .8
seconds. Then I want it to become invisible again and show another TextView for .8
seconds and so on. So basicly, it's like(textView1 pops up for a bit then disappears, then textView2 pops up for a bit then disappears...). There needs to be a good amount of time between each textView. My problem is finding a way to make my code wait a bit in between the:
findViewById(R.id.textView1).setVisibility(00000000); //makes it visible
and
findViewById(R.id.textView1).setVisibility(00000004); //makes it invisible
I have tried many different methods, but most either makes the textView stay invisible, because it gets to the .setVisibility(00000004)
to quickly, or it pauses the code, but never seems to become visible as if .setVisibility(00000000)
was ignored. This is what I am trying currently, but the textViews stay invisible.
int counter=0;
public void GamePlay(View view)
{
turns[counter]=(int)(4*Math.random()+1);
counter=0;
while(turns[counter]!=0)
{
if(turns[counter]==1)
{
findViewById(R.id.textView1).setVisibility(00000000);
HoldGame();
findViewById(R.id.textView1).setVisibility(00000004);
}
else if(turns[counter]==2)
{
findViewById(R.id.textView2).setVisibility(00000000);
HoldGame();
findViewById(R.id.textView2).setVisibility(00000004);
}
else if(turns[counter]==3)
{
findViewById(R.id.textView3).setVisibility(00000000);
HoldGame();
findViewById(R.id.textView3).setVisibility(00000004);
}
else if(turns[counter]==4)
{
findViewById(R.id.textView4).setVisibility(00000000);
HoldGame();
findViewById(R.id.textView4).setVisibility(00000004);
}
counter++;
}
}
public void HoldGame()
{
Timer timer=new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
}
}, 1*1000);
}