Sunday, June 2, 2013

[android-developers] Re: Problem restoring values after rotation in a custom view (when it is added twice to the layout)

The same issue was posted here not long ago... My assumption is that because both of your views have the same child IDs, the activity fails to store (or restore) the data appropriately.
You should handle these yourself (use onRetainInstanceState and onRestoreInstanceState/ onCreate) to save and update the view information properly or stop using view ids on the children (not tested it, but i believe that if you drop all ids from the children, the issue will be resolved. you'll need to find them by their order in the parent instead of their id).

On Sunday, June 2, 2013 1:44:26 PM UTC+3, charlie babitt wrote:
Hi!

I have the following problem:
I want to write a specialized Date Input view, which basically has a EditText, with button for clearing the input and another button opening a date picker.

Thefore I started with writing a ClearableTextView, which extends RelativeLayout. This view only has an EditText and the button for clearing the edit text. Now I implement a ClearableDatePicker which extends the ClearableTextView. It only adds the button for opening the Date Picker.
In the layout of the activity I add it using 

<com.test.view.ClearableDatePicker
                android:id="@id/cdpBirthDate"
                android:hint="@string/tvBirthDate"
                android:padding="3dip"
                android:scrollHorizontally="true" />

Everything works great until I add a second one and then rotate the device. Now something really strange happens. The value of the second EditText is restored to the first one and the second one is empty. I can't explain this behavior. Does anyone have an idea?

Thanks
Charlie

--
--
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+unsubscribe@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 unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate