i was trying to tell you use the ViewHolder pattern as in the list demos...and just added that you can use TwoLineListItem instead of creating your own..
On Fri, Mar 13, 2009 at 1:15 AM, Mariano Kamp <[email protected]>wrote: > Hi forandroid, > > I guess you're talking about the class TwoLineListItem [1], right? Out of > curiosity, not because I am trying to be a smart ass: Why would this be > faster? > > Cheers, > Mariano > > [1] > http://developer.android.com/reference/android/widget/TwoLineListItem.html > > > On Wed, Jan 14, 2009 at 10:51 AM, for android <[email protected]>wrote: > >> use the efficient list adapter >> >> And also you can use the TwoLineListitem.... >> >> >> On Wed, Jan 14, 2009 at 2:23 PM, Mariano Kamp <[email protected]>wrote: >> >>> *bump* ;-) >>> >>> >>> On Sun, Jan 11, 2009 at 7:10 PM, Mariano Kamp <[email protected]>wrote: >>> >>>> Hi, >>>> I have a performance problem in a ListView. The problem seems to be >>>> that it takes too long to setup each individual row. It scrolls very, very >>>> painfully slow, because of that. >>>> >>>> The actual code renders an Entry differently depending on the read >>>> state and if it is changed. When not using this code and just plainly >>>> called >>>> setText() on the TextViews it is reasonable fast. Also the content is >>>> HTML. >>>> >>>> Am I doing something terribly wrong here? >>>> >>>> >>>> <?xml version="1.0" encoding="utf-8"?> >>>> <RelativeLayout xmlns:android=" >>>> http://schemas.android.com/apk/res/android" >>>> android:layout_width="fill_parent" android:layout_height= >>>> "wrap_content"> >>>> >>>> <TextView android:id="@+id/feed_title" android:layout_width= >>>> "fill_parent" >>>> android:layout_height="wrap_content" android:textSize="11sp" >>>> android:paddingTop="3px" /> >>>> <TextView android:id="@+id/entry_title" android:layout_width= >>>> "fill_parent" >>>> android:layout_height="wrap_content" android:layout_below= >>>> "@id/feed_title" >>>> android:textSize="15sp" android:paddingBottom="3px" /> >>>> </RelativeLayout> >>>> >>>> class EntryListAdapter extends BaseAdapter { >>>> >>>> [..] >>>> >>>> public View getView(int position, View convertView, ViewGroup parent) { >>>> View rowView = convertView != null ? convertView : activity >>>> .findViewById(R.layout.entry_row); >>>> >>>> if (rowView == null) >>>> rowView = inflater.inflate(R.layout.entry_row, parent, false); >>>> >>>> Entry entry = entries.get(position); >>>> --> slow version >>>> EntryViewHelper.populateEntryView(rowView, entry); >>>> <-- >>>> -- OR -- >>>> --> (somewhat) fast version >>>> TextView entryTitleView = (TextView) rowView.findViewById(R.id. >>>> entry_title); >>>> TextView feedTitleView = (TextView) rowView.findViewById(R.id. >>>> feed_title); >>>> >>>> >>>> feedTitleView.setText(entry.getFeedTitle()); >>>> entryTitleView.setText(entry.getTitle()); >>>> <-- >>>> return rowView; >>>> } >>>> } >>>> >>>> class EntryViewHelper { >>>> [..] >>>> >>>> static void populateEntryView(View view, Entry entry) { >>>> >>>> TextView entryTitleView = (TextView) view >>>> .findViewById(R.id.entry_title); >>>> TextView feedTitleView = (TextView) view.findViewById(R.id.feed_title >>>> ); >>>> >>>> feedTitleView.setText(U.renderTitleToSpannedString( >>>> entry.getFeedTitle(), entry.getFeedTitleType())); >>>> entryTitleView.setText(U.renderTitleToSpannedString(entry.getTitle(), >>>> entry.getTitleType())); >>>> >>>> int style = Typeface.NORMAL; >>>> if (!entry.isRead()) >>>> style |= Typeface.BOLD; >>>> if (entry.isReadStatePending()) >>>> style |= Typeface.ITALIC; >>>> >>>> entryTitleView.setText(U.renderTitleToSpannedString(entry.getTitle(), >>>> entry >>>> .getTitleType())); >>>> feedTitleView.setText(U.renderTitleToSpannedString( >>>> entry.getFeedTitle(), entry.getFeedTitleType())); >>>> >>>> entryTitleView.setTypeface(Typeface.DEFAULT, style); >>>> } >>>> } >>>> >>>> .. >>>> import android.text.Html; >>>> import android.text.Spanned; >>>> import android.text.SpannedString; >>>> .. >>>> class U { >>>> static Spanned renderTitleToSpannedString(String titleString, >>>> String titleType) { >>>> Spanned title = null; >>>> if ("html".equals(titleType) || "xhtml".equals(titleType)) >>>> title = Html.fromHtml(titleString); >>>> else >>>> title = new SpannedString(titleString); >>>> return title; >>>> } >>>> } >>>> >>>> Btw. I re-use the convert view etc. The performance degradation only >>>> happens when I style the output. >>>> >>>> Cheers, >>>> Mariano >>>> >>> >>> >>> >>> >> >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

