How to dynamically add views to custom layout based on size

by Brent Edwards » Sun, 29 Nov 2009 04:21:06 GMT


Sponsored Links
 I have created a custom GameBoard class which derives from
TableLayout.  I have also a created custom GamePiece class to be
placed on this game board that derive from ImageView.  My goal is to
measure the size of the GameBoard and dynamically add a variable
number GamePieces based on the size of the GameBoard.

To accomplish this, I have overridden onSizeChanged in GameBoard to
determine the size of the board and I calculate how many GamePieces to
place based on this width and height.  I have log messages that output
whenever a GamePiece is added to the GameBoard (via addView).  Though
I can see the messages coming through, I never see the GamePieces.

I have found through testing that I can place a fixed number of
GamePieces (which are visible) on the GameBoard in the GameBoard's
constructor, but I cannot know it's dimension at that time.

I have also tried adding the GamePieces in the onLayout method, but
get the same results as onSizeChanged.

What is the correct method for determining the size of my GameBoard
and placing a variable number of GamePieces based on that size?

Thanks in advance,
Brent

--



Other Threads

1. Streaming sdp file by Opencore

Hi All
   I have some question about streaming video by sdp. In serive site,
I have a Darwin Streaming Server. In client, I try to program a new
project to show streaming vide. I use Video View. Just like below
program:
    private String path = "rtsp://63.105.122.35:80/
AFTVHorrorH26496.sdp";
    mVideoView.setVideoPath(path);
    mVideoView.setVideoURI(Uri.parse(path));
    mVideoView.start();
But it cannot work. Anyone know about this qestion? I just have some
question, Please help me!!
1.Can Andoird emulator play streaming by sdp?
2.If yes, What's version? All or new ones?
3.If not, Any suggest for my?
Thank you for your help!!

-- 

2. Bayeux Client on Android

Hi, All

I am a new comer to Android platform - working on a bayeux client on
Android to push the messages and applications from server to the
client (Android device) over HTTP. Can anyone point me to a sample or
tutorial to start with?

Also just find a cometd Java client that implements the bayeux client
on Android, but the download link does not work:
http://blogs.webtide.com/dyu/entry/android_chat_using_jetty_cometd

Any help would be appreciated. Thanks!


Nelson

-- 

3. No Build option in the New Android Project dialog Box in the Eclipse IDE

4. HelloAndroid.apk has a CERT.RSA File of Size 0

5. ADB and T-Mobile Pulse

6. Picasa API does not work as expected under Android

7. Gyrometer granularity and running app in background?