TextView.onSaveInstanceState() saves details about the TextView into a
Bundle that is passed between the two Launcher instances when
orientation is changed.  By default, those values are keyed off
View.getId().  This means if your id's collide with those of another
widget, your views may overwrite the state of someone else widget.

When restoring the state, that ClassCastException is triggered if it
tries restoring the incorrect type of state.  (For example, the state
from a ImageView applied to a TextView.)


-- 
Jeff Sharkey
jshar...@android.com

On Fri, Nov 6, 2009 at 10:55 PM, NewPa <shiji...@gmail.com> wrote:
> Hi Jeff,
>    I add setting android:saveEnabled="false"  for all the views in
> the widget, then widget works well. Thanks for your kindly help. But I
> don't know why this setting can fix the problem, could you please
> explain to me?
>
> On Nov 3, 6:01 am, Jeff Sharkey <jshar...@android.com> wrote:
>> For the views that have ids, try setting android:saveEnabled="false"
>> so that they don't bundle up their state.
>>
>> j
>>
>>
>>
>> On Sat, Oct 31, 2009 at 8:00 PM, NewPa <shiji...@gmail.com> wrote:
>> > Hi String,
>> >     I use static var, i will test it.
>> > Hi Jeff,
>> >   Here is my layout file content. it seems will cause confliction
>> > with others:
>> > Thanks for your kindly help.
>>
>> > <?xml version="1.0" encoding="UTF-8"?>
>> > <LinearLayout android:id="@+id/LinearLayout01"
>> >        android:layout_width="72dp" android:layout_height="72dp"
>> >        android:background="@drawable/bg" android:orientation="vertical"
>> >        android:paddingTop="3dp"
>> >        xmlns:android="http://schemas.android.com/apk/res/android";>
>>
>> >        <TextView android:text="TextView01"
>> >                android:layout_width="wrap_content" android:textStyle="bold"
>> >                android:layout_height="14sp" android:id="@+id/TVWeeks"
>> >                android:textSize="12sp"
>> >                android:paddingLeft="8dp"
>> >                android:textColor="#000000">
>> >        </TextView>
>>
>> >        <ImageView android:id="@+id/ImageView01"
>> >                android:layout_width="65sp"
>> >                android:src="@drawable/line"
>> >                android:paddingLeft="5dp"
>> >                android:layout_height="2sp">
>> >        </ImageView>
>> >        <TextView android:text="TextView01"
>> >        android:paddingLeft="8dp"
>> >        android:textSize="12sp"
>> >                android:layout_width="wrap_content" 
>> > android:textColor="#000000"
>> >                android:layout_height="14sp" android:id="@+id/TVHeight">
>> >        </TextView>
>>
>> >        <TextView android:text="TextView01"
>> >        android:textSize="12sp"
>> >        android:paddingLeft="8dp"
>> >                android:layout_width="wrap_content" 
>> > android:textColor="#000000"
>> >                android:layout_height="16sp" android:id="@+id/TVWeight">
>> >        </TextView>
>>
>> > <ImageView android:id="@+id/ImageView02"
>> >                android:layout_width="65sp"
>> >                android:src="@drawable/line"
>> >                android:paddingLeft="5dp"
>> >                android:layout_height="2sp">
>> >        </ImageView>
>> >        <TextView android:text="TextView01" android:textColor="#000000"
>> >        android:textSize="12sp"
>>
>> >        android:paddingLeft="8dp"
>> >                android:layout_width="wrap_content"
>> >                android:layout_height="16sp"
>> >                android:id="@+id/TVMomWeiAdded">
>> >        </TextView>
>>
>> > </LinearLayout>
>>
>> > On Oct 31, 4:13 am, Jeff Sharkey <jshar...@android.com> wrote:
>> >> There can be issues if the android:id's in your layouts conflict with
>> >> other widgets.  This was fixed in Eclair by having Launcher create
>> >> separate SparseArray "jails" for each widget to store their state
>> >> into.  It's change 09ddc08b... to be specific.
>>
>> >> Could you post your layout file, or describe how you're allocating ids?
>>
>> >> j
>>
>> >> On Thu, Oct 29, 2009 at 12:25 AM, String <sterling.ud...@googlemail.com> 
>> >> wrote:
>>
>> >> > On Oct 29, 6:51 am, Eong <eong.c...@gmail.com> wrote:
>>
>> >> >> Yeap. My users reported this to me today. The OTA release has the same
>> >> >> bug. They should push a fixed update right now.
>>
>> >> > FWIW, I'm not convinced it's a bug in Donut. I'm not seeing the same
>> >> > issue in my widgets, and I do plenty in onUpdate. If you genuinely
>> >> > think it's a platform bug, produce a minimal test case and write it
>> >> > up, please.
>>
>> >> > I'm assuming you're aware that keyboard open/close on an HTC Dream
>> >> > destroys and recreates the widget instance, so if (for example) you're
>> >> > referencing any static vars in your code, those will no longer exist.
>> >> > I'm also assuming that you're sending a complete set of views to the
>> >> > RemoteViews object every time, or you probably would have had trouble
>> >> > before now. But you might check those things. :^)
>>
>> >> > String
>>
>> >> --
>> >> Jeff Sharkey
>> >> jshar...@android.com
>>
>> > --
>> > 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
>>
>> --
>> Jeff Sharkey
>> jshar...@android.com
>
> --
> 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
>



-- 
Jeff Sharkey
jshar...@android.com

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