No, the documentation at
http://code.google.com/android/reference/android/widget/ArrayAdapter.html
shows two constructors to which you can pass a List<T>.
On Sat, Sep 6, 2008 at 11:20 PM, squeakypants <[EMAIL PROTECTED]> wrote:
>
> Thanks, that did it! :)
>
> The docs said Object[], so I assumed only an array could be passed.
>
> --squeakypants
>
> On Sep 6, 9:37 pm, "Romain Guy" <[EMAIL PROTECTED]> wrote:
>> It's because you passed an array of Integer[]. Pass a List<Integer>
>> instead and you will be able to add/remove/insert/etc.
>>
>>
>>
>> On Sat, Sep 6, 2008 at 3:40 PM, squeakypants <[EMAIL PROTECTED]> wrote:
>>
>> > I've created an ArrayAdapter<Integer> for a ListView as such:
>> > aa = new ArrayAdapter<Integer>(
>> > this,
>> > R.layout.centered_list,
>> > new Integer[] {0,1,2});
>> > (very similarly, anyway)
>>
>> > If I try using aa.add(3) or aa.insert(3,3), I get an
>> > UnsupportedOperationException. Here's the full output:
>> > 09-06 18:22:07.102: WARN/dalvikvm(1643): threadid=3: thread exiting
>> > with uncaught exception (group=0x40010e28)
>> > 09-06 18:22:07.102: ERROR/AndroidRuntime(1643): Uncaught handler:
>> > thread main exiting due to uncaught exception
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643):
>> > java.lang.UnsupportedOperationException
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > java.util.AbstractList.add(AbstractList.java:399)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.widget.ArrayAdapter.insert(ArrayAdapter.java:194)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > the.android.DiceRoller.DiceRoller.add_num(DiceRoller.java:52)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > the.android.DiceRoller.DiceRoller$3.onClick(DiceRoller.java:139)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.view.View.performClick(View.java:2068)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.view.View.onTouchEvent(View.java:3453)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.widget.TextView.onTouchEvent(TextView.java:4347)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.view.View.dispatchTouchEvent(View.java:3108)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:841)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:841)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:841)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:841)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:841)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > com.android.internal.policy.impl.PhoneWindow
>> > $DecorView.superDispatchTouchEvent(PhoneWindow.java:1552)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneW
>> > indow.java:
>> > 1059)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.app.Dialog.dispatchTouchEvent(Dialog.java:562)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > com.android.internal.policy.impl.PhoneWindow
>> > $DecorView.dispatchTouchEvent(PhoneWindow.java:1536)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.view.ViewRoot.handleMessage(ViewRoot.java:1088)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.os.Handler.dispatchMessage(Handler.java:88)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.os.Looper.loop(Looper.java:123)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > android.app.ActivityThread.main(ActivityThread.java:3708)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > java.lang.reflect.Method.invokeNative(Native Method)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > java.lang.reflect.Method.invoke(Method.java:492)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > com.android.internal.os.ZygoteInit
>> > $MethodAndArgsCaller.run(ZygoteInit.java:734)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:492)
>> > 09-06 18:22:07.160: ERROR/AndroidRuntime(1643): at
>> > dalvik.system.NativeStart.main(Native Method)
>>
>> > The only problem I can think of is that it is an "Array"Adapter,
>> > rather than another form of container, but I assumed that was only
>> > because you input an array. Why even have add, insert, or remove
>> > methods?
>>
>> > Does anyone else get this exception? Does anyone have a fix?
>>
>> --
>> Romain Guywww.curious-creature.org
>
> >
>
--
Romain Guy
www.curious-creature.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new Android 0.9 SDK beta!
http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---