Right. In this case, neither LinearLayout or merge is needed.

Thanks for your help.


On Jun 23, 8:13 am, Josh Guilfoyle <[email protected]> wrote:
> This is not a case where <merge> is necessary.  If you have only 1
> widget ultimately, icon_row or icon_text, you simply must put that at
> the root of the XML.  It is not necessary for you to wrap it in a
> LinearLayout, nor is it necessary for your adapter to work exclusively
> with a ViewGroup.
>
> On Jun 22, 12:23 pm, az9702 <[email protected]> wrote:
>
> > Josh,
>
> > I have getViewTypeCount (2 here)  & getItemViewType (0/text_row, 1/
> > icon_row) in my adapter so it knows about the two row types.
> > ConvertView is set to the correct row type.
>
> > The question is how correctly apply merge & remove
> > LinearLayout given:
>
> > * layout/icon_row.xml w/ <LinearLayout>/icon_row
> > * layout/icon_text.xml w/ <Linearlayout>/icon_text
>
> > If I simply replace <LinearLayout> with <merge> in above xml's,
> > inflate will throw exception w/o a ViewGroup parent.
>
> > So I need to pass in ViewGroup to my Adapter somehow.
>
> > Thanks.
>
> > On Jun 22, 11:48 am, Josh Guilfoyle <[email protected]> wrote:
>
> > > You definitely don't want to access the list directly from the
> > > adapter.  Instead for your design what you'd want to do is remove the
> > > outer linear layout if you can and just have two separate XML files
> > > with only 1 view each (text_row or icon_row).  Then in your adapter
> > > override the methods getItemViewType and getViewTypeCount.  These
> > > methods are provided for you to have two or more different types of
> > > layouts for certain rows based.
>
> > > On Jun 22, 10:16 am, az9702 <[email protected]> wrote:
>
> > > > Hi,
>
> > > > I have a ListView with two types of custom views.  It inflates
> > > > "icon_row" view if  a drawable exists or a "text_row" if not.
>
> > > > I came up w/ custom views for icon_row & text_row & include them in
> > > > their XML like so :
>
> > > > //text_row.xml
> > > > <LinearLayout ....>
> > > >    < com.test.android.ALS.text_row
> > > >             ...
> > > >             app:text1="..."
> > > >             app:textSize1=".."
> > > >     >
> > > > /LinearLayout>
>
> > > > //icon_row.xml
> > > > <LinearLayout ...>
> > > >     <com.test.android.ALS.icon_row
> > > >         ...
> > > >         app:imgSrc="..."
> > > >      >
> > > > /LinearLayout>
>
> > > > I have another main.xml that defines the ListView which is set to an
> > > > adpater.
>
> > > > In my adatper's getView (in separate class file), I will inflate:
>
> > > >     if(convertView == null) {
> > > >          if(<no drawable>) {
> > > >              convertView = mInflater.inflate(R.layout.text_row. null);
> > > >         }     else {
> > > >               convertView = mInflater.inflate(R.layout.icon_row,
> > > > null);
> > > >         }
> > > >     }
>
> > > > Both of icon_row, text_row have a root LinearLayout that seem to be
> > > > redundant. The row layouts can be directly attached ListView.  This
> > > > may be a case for "merge".
>
> > > > To use merge, I need a ViewGroup in inflate & that ViewGroup should be
> > > > my ListView.
>
> > > > My question is how to obtain a reference to the ListView w/o making
> > > > the adapter as an inner class to the main activity.
>
> > > > Thanks in advance.
>
>
--~--~---------~--~----~------------~-------~--~----~
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