I have a problem that I'm sure it's not to complicated to resolve but no matter what I do it just won't work !
Here's my problem : I have this layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/backgroundshape"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text_timer"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:textColor="#f44242"
android:textSize="95dp"
android:textStyle="bold"
/>
<ImageView
android:id="@+id/image_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="25dp"
android:layout_centerVertical="true"/>
<ImageView
android:id="@+id/image_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="25dp"
android:layout_centerVertical="true"/>
</RelativeLayout>
The point is to click on the last ImageView that take all the screen to begin to instantiate the other Views. Here's how I do it :
public class GameScreen extends Activity {
ImageView imgEmpty, img1, img2;
TextView tvTimer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_second);
img1 = (ImageView)findViewById(R.id.image_1);
img2 = (ImageView)findViewById(R.id.image_2);
imgEmpty = (ImageView)findViewById(R.id.image_empty);
imgEmpty.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
img1.setBackgroundResource(R.drawable.feuille);
img2.setBackgroundResource(R.drawable.feuille);
tvTimer.setTextSize(95);
for(int i=0; i<3; i++) {
imgEmpty.setVisibility(View.GONE);
try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); Log.d("Ratatataaa","Y passe pas !!!!"); }
tvTimer.setText(""+i);
view.invalidate();
}
}
});
tvTimer = (TextView)findViewById(R.id.text_timer);
tvTimer.setTextSize(50);
tvTimer.setText("Ready ?");
}
}
No matter what I do (invalidate(),...), the screen only refresh at the end of the onClick(View view)
please help