The initialization method:
private void initInfectusView() {
setFocusable(true);
Resources r = this.getContext().getResources();
resetTiles(2);
setTileCounts(8,8);
setTileSize();
loadTile(Cell.MOM, r.getDrawable(R.drawable.mothercell));
loadTile(Cell.STEM, r.getDrawable(R.drawable.stemcell));
setTile(1,2,1);
}
some of the methods called
protected void setTileCounts(int x, int y){
mXTileCount = x;
mYTileCount = y;
}
protected void setTileSize(){
mTileSize = (int) Math.min(
Math.floor(this.getWidth()/mXTileCount),
Math.floor(this.getHeight()/mYTileCount));
}
public void loadTile(int key, Drawable tile) {
String mTileSizeVal = (String) Integer.toString(mTileSize);
Log.i("MyTag", mTileSizeVal);
Bitmap bitmap = Bitmap.createBitmap(mTileSize, mTileSize,
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
tile.setBounds(0, 0, mTileSize, mTileSize);
tile.draw(canvas);
mTileArray[key] = bitmap;
}
The log reports MyTag with a value of 0.
This causes an error and the program force closes. I can give a
constant value for the bounds such as 8 and it causes an inflation
error in the xml (I still haven't managed to fix that yet, but for now
one problem at a time).
What can I do to ensure that the mTileSize gets set before loadTile
runs.
It occurs to me that the problem might be with the code
"this.getHeight()" and "this.getWidth()". I was under the impression
that those calls would return the value of the height and width of a
view, but maybe I am using them incorrectly.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en