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 <jast...@gmail.com> 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 <az9...@gmail.com> 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 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 -~----------~----~----~----~------~----~------~--~---