Penalty for wrong answer: you have to share your pain meds.... ;)

Mark
On Mar 24, 2012 6:45 PM, "Justin Anderson" <[email protected]> wrote:

> Kostya,
>
> Thanks for catching my mistake!  I had surgery for a deviated septum a
> couple days ago and I'm on some pretty heavy meds... Serves me right for
> trying to answer some questions while I'm obviously so very loopy!  :-)
>
> Thanks,
> Justin Anderson
> MagouyaWare Developer
> http://sites.google.com/site/magouyaware
>
>
> 2012/3/24 Kostya Vasilyev <[email protected]>
>
>> 25 марта 2012 г. 0:55 пользователь Justin Anderson
>> <[email protected]> написал:
>> >> Apen sorry i dint notice ur suggestion, no it's not about the name,
>> >> hmm i think it's something wrong with the order of the blocks...
>> >
>> >
>> > No, it IS about the name... Apen was correct (and that is what I was
>> trying
>> > to say before, but was REALLY tired so I apologize for the incoherent
>> > replies).
>> >
>> >
>> >> mNewDevicesArrayAdapter = new ArrayAdapter<String>(this,
>> >> R.layout.textviewlayout);
>> >
>> >
>> > That is incorrect... You should not be passing in an R.layout here...
>> you
>> > should be passing in an R.id
>>
>> No.
>>
>> The two-argument constructor takes a *layout* id:
>>
>>
>> https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/ArrayAdapter.java#L96
>>
>> and it's assumed that the layout consists of just one TextView at the
>> root.
>>
>>
>> https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/ArrayAdapter.java#L378
>>
>> So:
>>
>> res/layout/item_simple.xml:
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <TextView .... />
>>
>> and then:
>>
>> new ArrayAdapter(this, R.layout.item_simple)
>>
>> Constructor #2 takes a layout id and a view id:
>>
>>
>> https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/ArrayAdapter.java#L107
>>
>> and uses findViewId with the last (third) parameter locate the text
>> view within the layout:
>>
>>
>> https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/ArrayAdapter.java#L381
>>
>> res/layout/item_complex:
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <LinearLayout ... or something else >
>>  <TextView android:id="@+id/item_text_view .... />
>>  <ImageView ... or something else />
>> </LinearLayout>
>>
>> and then
>>
>> new ArrayAdapter(this, R.layout.item_complex, R.id.item_text_view)
>>
>> -- K
>>
>> --
>> 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]
>> 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 post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> 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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to