I have developed a layout to which i want to add multiple copies of the same 
child view. the child view is defined in a xml file. To add each child to 
its parent i am calling:
ChildView childView = new ChildView (context);
linearLayout.addView(childView ,new LayoutParams(LayoutParams.FILL_PARENT, 
LayoutParams.WRAP_CONTENT));            
the constructor of ChildView is as follows:
public ChildView (Context context)
{
    super(context);
    inflate(context, R.layout.child_view, this);
    checkBox = (CheckBox) findViewById(R.id.checkbox);
}
everything is working correctly and i can manipulate each checkbox 
correctly. however when the phone is rotated the restored state for each 
checkbox is the state of the last child. in this particular case I don't 
actually need to save the state as it can be restored from elsewhere so have 
managed to work around the problem by adding     
protected void dispatchRestoreInstanceState(SparseArray<Parcelable> 
container)
{
    dispatchThawSelfOnly(container);
}
to ChildView. however if i want to do something similar in future and do 
need to save the state what are my options? do I have to handle save and 
restore of state in ChildView? do i need to somehow assign a unique id to 
each checkbox (how would these be generated?). 

-- 
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