08 Sep 2012, 08:42
Generic-user-small

Fahimeh SH (4 posts)

I read Hello Android book and i dont understand some parts of the code.

super(context); in this code, what does it mean and what does it do?

this.game = (Game) context; why we wrote this? what does it do?

In android site is write that onSizeChanged() function is used for: “This is called during layout when the size of this view has changed” This meant that if to rotate the phone, this function causes the view of program to display true. this is true?

getRect(selX,selY,selRect); what does it mean and what does it do?

Log.d() what does it do?

Please help me. Cheers.

public class PuzzleView extends View { 
    private static final String TAG = "Sudoku" ; 
    private final Game game; 
    public PuzzleView(Context context) { 
    super(context); 
    this.game = (Game) context; 
    setFocusable(true); 
    setFocusableInTouchMode(true); 
  } 
 // ... 
} 

private float width; // width of one tile 
private float height; // height of one tile 
private int selX; // X index of selection 
private int selY; // Y index of selection 
private final Rect selRect = new Rect(); 
@Override 
protected void onSizeChanged(int w, int h, int oldw, int oldh) { 
    width = w / 9f; 
    height = h / 9f; 
    getRect(selX, selY, selRect); 
    Log.d(TAG, "onSizeChanged: width " + width + ", height "+ height); 
    super.onSizeChanged(w, h, oldw, oldh); 
 } 




 
  You must be logged in to comment