i thought by now you could read my mind :-)

assuming that the XML enclosed in the post is in res/layout/contact_view.xml

in the custom ListView...

LayoutInflater  inflater = LayoutInflater.from (this.context);

// passing null here, as i'm assuming that the ListView will hook the 
view up with its hierarchy
ContactView     contactView = (ContactView) inflater.inflate 
(R.layout.contact_view, null);

in the custom item View...

LinearLayout    top = (LinearLayout) findViewById (R.id.contact_top_layout);

"top" comes back null. if ContactView asks for its own children, the 
count comes back zero.

thanks in advance!



>The code would help :)
>
>On Mon, Sep 28, 2009 at 1:56 PM, Jason Proctor
><[email protected]> wrote:
>>
>>  i'm running into some issues inflating layouts and i wonder whether i
>>  have something basic wrong.
>>
>>  i have a ListView with a custom adapter etc, and of course the item
>>  View is custom too. i've been creating the item View in code, and
>>  everything works fine, including recycling them and all that. great.
>>  but i want to move the View into a resource, where all good Android
>>  views live, and weirdness is happening.
>>
>>  in the ListView's getView(), i get my inflater and inflate the view
>>  by ID. the view itself has its own XML file. i can inflate the top
>>  view, but i can't find anything by ID, and when asked for its
>>  children, nothing comes back.
>>
>>  are there funky rules for inflating views this way? is there a
>>  convention for how this should be done inside a ListView?
>>
>>  thanks -- (abbreviated) XML layout code enclosed...
>>
>>  <com.particlebrand.roboto.android.ContactView
>>         xmlns:android="http://schemas.android.com/apk/res/android";
>>         android:layout_width="fill_parent"
>>         android:layout_height="wrap_content"
>>         android:orientation="vertical"
>>         android:background="#ffffffff"
>>         >
>>         <!--
>>                 the top layout, with clickable user name header
>>                 and "contact" widget
>>         -->
>>         <LinearLayout
>>                 android:id="@+id/contact_top_layout"
>>                 android:layout_width="fill_parent"
>>                 android:layout_height="wrap_content"
>>                 android:orientation="horizontal"
>>                 >
>>                 <TextView
>>                         android:id="@+id/contact_user_name"
>>                         android:layout_width="fill_parent"
>>                         android:layout_height="wrap_content"
>>                         android:layout_weight="1"
>>                         android:background="#ffffffff"
>>                         android:textColor="#ff000000"
>>                         android:textSize="18px"
>>                 />
>>  ...
>>         </LinearLayout>
>>  </com.particlebrand.roboto.android.ContactView>
>>
>>
>>  --
>>  jason.vp.engineering.particle
>>
>>  >
>>
>
>
>
>--
>Romain Guy
>Android framework engineer
>[email protected]
>
>Note: please don't send private questions to me, as I don't have time
>to provide private support.  All such questions should be posted on
>public forums, where I and others can see and answer them
>
>

-- 
jason.vp.engineering.particle

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