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. Query contacts based on unformatted Phone numbers

We are getting a set of telephone numbers(pure numbers with no
formatting) from a remote web service. We need to display them in a
list. But before that we have to query the contacts database and show
"display name" of the contact instead of the phone number if there is
a match.

Question :
1. When we add a contact in our phone book using the native Contacts
application, the application does some sort of number formatting. For
e.g.: 1234567890 could be stored as 123-456-7890. Is this formatting
region/locale specific?
2. If i receive 1234567890 from the remote service will I have to
apply same formatting before I query the database or will the
ContentResolver for contacts take care of this and find appropriate
match for me?
3. Is there a documentation that describes what formatting is applied
when?

Let me know if I was not clear or if i need to add anything else.

Please help.

Thanks.

[This is a cross post:
http://stackoverflow.com/questions/3703233/query-contacts-based-on-telephone-numbers]

-- 

2. Regarding passing bitmap via aidl

Dear All,
   I need some help on this i am passing a bitmap via AIDL (
myInterface.aidl) file, Its working fine but it takes lot of time ( 150 ms
to 250 ms ) .
Is there any better way through which i can pass the bitmap to myservice or
via myinterface ?

Thanks a lot in Advance.

Thanks and Regards,
  Vivek R

-- 

3. Doesn any body konw how to contact with Android Market support team?

4. kernel panic!-----------

5. LVL, ServerManagedPolicy...

6. How to know who has registered the developer name on Android Market

7. Question about on device-added-*