> ImageView[] var1 = new ImageView[4]; > var1[0].SetId(100); Wouldn't work with any non-primitive type. You only get an array of handles, need to initialize each object explicitly: ... var1[0] = new ImageView(...) var1[0].setId(100); ...
With regards to the 1st question, you can create an instance of RelativeLayout.LayoutParams and use methods such as addRule(...), then specify it when you attach a view to its parent (addView(view, params) if I remember correctly). I still recommend that you think again about using XML for most of your layouts. As the UI gets more complicated, your code will become a mess. XML layouts in Android are very flexible, it takes a while to learn the tricks, but it's worth it. You'll waste more time looking for workarounds if you choose to ignore XML. On Feb 24, 10:09 pm, Kofa <[email protected]> wrote: > First of all, sorry for the delay to reply...=P > I have just read your message... i have started already and I have > developed much I think =) > I will tell you what I have, I will focus on the "engine"(GUI): > a main menu with buttons, one with START GAME.... goes to another > activity, there another button to start the game itself, the "engine": > a new activity is called, it loads almost everything from the 2 > layouts from code, not XML, i think it's more flexible. > FIRST LAYOUT: a imageview with a huge picture on it.... it has a - > onTouchEvent- that makes the scroll works... > loads too some imageviews(citys) in the same layout as the map, so > those images move with the scroll. > The other layout, the main layout, has a imageview and a > button.........and here comes the 2 problems that appeared =P: > -How can I arrange views in a RelativeLayout, but on code, not XML. > -and I can't think out how to create an array of ImageViews. > > I tried something like this but didn't work, for example to set an ID: > > ImageView[] var1 = new ImageView[4]; > > var1[0].SetId(100); > > AND SORRY FOR MY ENGLISH =P -- 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

