It's the right way to do it :)
On Mon, Feb 1, 2010 at 11:24 PM, Ryan Moulton wrote:
> Thanks for the quick response! If I'd known I could get an answer so
> quickly here I'd have posted _last_ week. :)
> I can debug it from here then.
>
> Is the best way to do this View.inflate(activity,
> R.layout.what_id_like_to_inflate, null)?
>
>
>
> On Feb 1, 11:07 pm, Romain Guy wrote:
>> Inflating a views tree always creates new instances of views, there's
>> no singleton. Without seeing your code, I cannot tell you what you are
>> doing wrong unfortunately.
>>
>>
>>
>>
>>
>> On Mon, Feb 1, 2010 at 11:04 PM, Ryan Moulton wrote:
>> > Hi everyone. Just getting started with developing for Android, so
>> > apologies if there's an obvious answer.
>>
>> > I'm working on an application in which it's necessary to
>> > programmatically change the entire structure of the UI. What I would
>> > like to be able to do is specify a subtree of the UI in xml, and then
>> > instantiate that multiple times as required throughout the tree. For
>> > instance, if I need the user to set a numerical value, I'd like to use
>> > xml to define all the widgets involved, increment and decrement
>> > buttons for instance, and then reference this same file whenever I
>> > need a UI of that sort.
>>
>> > Unfortunately, When I inflate the xml multiple times, I get the
>> > following exception.
>>
>> > IllegalStateException
>> > "The specified child already has a parent. You must call removeView()
>> > on the child's parent first."
>>
>> > This I'm assuming is because Inflating isn't creating a new object
>> > each time, but rather creating a static singleton. Is there a good way
>> > to do what I'm hoping to do, or should I abandon trying to use the xml
>> > interface?
>>
>> > -Ryan
>>
>> > --
>> > 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
>>
>> --
>> Romain Guy
>> Android framework engineer
>> romain...@android.com
>>
>> Note: please don't send private questions to me, as I don't have time
>> to provide private support. All such questions should be posted on
>> public forums, where I and others can see and answer them
>
> --
> 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
>
--
Romain Guy
Android framework engineer
romain...@android.com
Note: please don't send private questions to me, as I don't have time
to provide private support. All such questions should be posted on
public forums, where I and others can see and answer them
--
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