I want some delay between two thing inside an OnItemClick,but actually nothing happens. If I run it, and click ,everything stops as long as is set the sleep, then it changes the pic at the same time.I would like to change the first pic. then Sleep then change the other.
gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// clicks=0;
int row_no = position / 3;
int col_no = position % 3;
if(clicks==0)
{
((ImageView) gv.getChildAt(position)).setImageResource(R.drawable.kor);
matrix[row_no][col_no]=1;
// clicks++;
}
if(gepLephet())
{
try {
Thread.sleep(400);
} catch (InterruptedException e) {
e.printStackTrace();
}
finally{
int posAi=gep();
((ImageView) gv.getChildAt(posAi)).setImageResource(R.drawable.iksz);
matrix[posAi/3][posAi%3]=2;
}
// Toast.makeText(getApplicationContext(),"Random: "+posAi, Toast.LENGTH_SHORT).show();
}
/* else if(clicks==1)
{
((ImageView) gv.getChildAt(position)).setImageResource(R.drawable.iksz);
matrix[row_no][col_no]=2;
clicks--;
}*/
// Toast.makeText(getApplicationContext(), "position: " + position +"Random: "+posAi, Toast.LENGTH_SHORT).show();
// if(matrix[0][0]==matrix[0][1]&&matrix[0][1]==matrix[0][2]){text.setText("WIN");}
if(isWinO())
{
text.setText("O WIN");
}
if(isWinX())
{
text.setText("X WIN");
}
}
;
});