Hi,

Just inflate from the xml each time you want a new instance of that particular 
view. Like this:

View innerRL = LayoutInflater.from(context).inflate(R.layout.inner_view, null);

/Anders

-----Original Message-----
From: android-developers@googlegroups.com 
[mailto:android-develop...@googlegroups.com] On Behalf Of krishna
Sent: den 8 juni 2010 02:37
To: Android Developers
Subject: [android-developers] Dynamically obtaining several instance of a view 
item defined in layout/xml file

I have a relative layout (let's say innerRL place in layout
inner_view.xml) which I wanna add to another layout (main_layout), I
wanna dynamically add multiple instances of innerRL. Specifying
innerRL in xml gives me ease of maintenance (as against doing totally
in the code), however I want to be able to add several instances
dynamically. Using findViewById(resource_id) gives me that particular
instance, should I have to use clone()?

One other approach I see is ArrayAdapter, but it seems overkill.

-Krishna

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to