The code below replaces the activity's content view (the root of view hierarchy) with a new LinearLayout.

If you want to keep your existing layout around, do this:

1 - declare a LinearLayout placeholder in your layout xml file, give it an ID.

2 - instead of creating a new LinearLayout, get it by calling findViewById.

3 - don't call setContentView

-- Kostya

28.07.2010 8:13, ethan пишет:
This is the code that i used :

LinearLayout mLinearLayout;
mLinearLayout = new LinearLayout(this);

ImageView i = new ImageView(this);
     i.setImageResource(R.drawable.cow_icon);
     i.setAdjustViewBounds(true); // set the ImageView bounds to match
the Drawable's dimensions
     i.setLayoutParams(new
Gallery.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));

     //Add the ImageView to the layout and set the layout as the
content view
     mLinearLayout.addView(i);
     setContentView(mLinearLayout);


With this code, i can see the image getting didplayed but it goes on a
different layout. It doesnt display on the current layout.
Is there a way i can display this in the current layout ?


On Jul 27, 12:18 pm, Kostya Vasilyev<kmans...@gmail.com>  wrote:
You could use one image view and several different images with varying
number of flowers.

Or create the required number of image views from code, all using the same
image.

Or declare four image views in your layout and manage their visibility from
code.

--
Kostya Vasilyev --http://kmansoft.wordpress.com

27.07.2010 21:11 пользователь "ethan"<puripun...@gmail.com>  написал:

Ok. So in this case, is there a way to dynamically create imageviews
from the code (not xml) based on number of images to display ?
Or should i just statically create 4 imageviews and only populate them
based on the number of flowers i want to display ?

On Jul 27, 10:52 am, Justin Anderson<janderson....@gmail.com>  wrote:

No... displaying the number...
On Tue, Jul 27, 2010 at 8:25 AM, ethan<puripun...@gmail.com>  wrote:
You are correct.
In...
<android-beginners%252bunsubscr...@googlegroups.com<android-beginners%25252bunsubscr...@googlegroups.com>
<android-beginners%25252bunsubscr...@googlegroups.com<android-beginners%2525252bunsubscr...@googlegroups.com>



For more options, visit this group at
http://groups.google.com/group/androi...


--
Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to