I read Hello Android book and I don't understand some parts of the code.
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);
}
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?
The Android site says 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?
Please help me. Cheers.