1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
for(i=0;i<9;i++)
{
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(100 , 100);
if(p>=0 && p<3)
params.setMargins(5*22*p, 8, 5, 5);
else if(p>=3 && p<6)
{
params.setMargins(5*22*v, 118, 5, 5);
v++;
}
else
{
params.setMargins(5*22*t, 228, 5, 5);
t++;
}
tabB[i]=new Button(this );
tabB[i].setId(i);
this.addContentView(tabB[i],params);
this.setVisible(true);
p++;
tabB[i] = (Button) findViewById(tabB[i].getId());
tabB[i].setBackgroundResource(R.drawable.vide);
tabB[i].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
changeImage(i);
}
});
}
public void changeImage(int id)
{
if(nbTours%2==0)
tabB[id].setBackgroundResource(R.drawable.croix);
else
tabB[id].setBackgroundResource(R.drawable.rond);
tabB[id].setEnabled(false);
nbTours++;
} |
Partager