On 3 July 2012 12:48, jean-francois garreau <[email protected] > wrote:
> Ok so can you please explain me how to do a view like this : > > ---------------------- > *NameMovie* > 1h20min > 11:00am | 2:00pm | *4:00pm* | 8:00pm | 10:00pm > --------------------- > > ---------------------- > Text(in bold) > SubText(in gray) > Text1 (in gray) Text2 (in gray) Text3 (in bold) Text4 (normal) > --------------------- > > I won't use viewHolder because my CustomView doesn't inherites from > LinearLayout, I don't any xml file. I'm using a class that inherites from > View. > Your class inherits from View, therefore it has View.setTag() and View.getTag(), to hold on to children Views within each list item. Each list item has all those sub-views, but each of sub-views has a different atributes (text, text color, ...) set durring each ListAdapter.getView(). This means that your convertView reference passed into getView will have Tag object set with all your sub-views ready to be customised for the given list element. > Considerating that I don't know in advance how many Texts in gra, same > thing for Text in bold and Text normal. AND I have to take care to cariage > returns . > See Mark's comment. If you can get away with one View. If however each of those times is clickable, then just set max number of TextViews in each list element, as simply removing unused ones by calling setVisibility(INVISIBLE) on each one. > > I first use this model : > > <LinearLayout > align:'vertical' > > > <TextView id="movieName"/> > <TextView id="timeMovie"/> > <TextView id="showtimes"/> > </LinearLayout> > > And with the view holder pattern it works but I have low performance for > the generation of the string : 11:00am | 2:00pm | *4:00pm* | 8:00pm | > 10:00pm because I need to use a HTML paint > > So after talking with lots of people I decided to write my own View > inheriting from View. The problem is : according to time of day, the view > will show : > 11:00am | 2:00pm | *4:00pm* | 8:00pm | 10:00pm > and after 11:00am | 2:00pm | 4:00pm | *8:00pm* | 10:00pm > etc. > > And according to the couple movie / cinema, I don't have the same number > of showtimes so I can't say that I will use 4 textView for the showtimes > because it will be wrong for the next movie to print. > > Or maybe I don't have understand how to use the ViewHolderPattern... > In my Adapter, I directly use the viewObjects. How can i use the > viewHolderPattern if my view inherites from view and don't have any view > element in it ? > > regards > > > Le mardi 3 juillet 2012 13:20:55 UTC+2, Mark Murphy (a Commons Guy) a > écrit : > >> On Tue, Jul 3, 2012 at 7:16 AM, jean-francois garreau >> <jean.francois.garreau@gmail.**com <[email protected]>> >> wrote: >> > I already saw that presentation and I can't use the ViewHolder pattern >> > because i need a customView. >> >> That makes absolutely no sense whatsoever. >> >> - TextView inherits from View >> - ImageView inherits from View >> - CheckableTextView inherits from View >> - your custom View subclass inherits from View >> >> And: >> >> - TextView works just fine with the ViewHolder pattern >> - ImageView works just fine with the ViewHolder pattern >> - CheckableTextView works just fine with the ViewHolder pattern >> >> Hence, I am fairly comfortable that for any well-written custom View >> subclass, the ViewHolder pattern can apply. There should be nothing >> magic about your particular subclass of View compared to any other. >> >> -- >> Mark Murphy (a Commons Guy) >> http://commonsware.com | http://github.com/commonsguy >> http://commonsware.com/blog | http://twitter.com/commonsguy >> >> _The Busy Coder's Guide to Android Development_ Version 3.7 Available! >> > > Le mardi 3 juillet 2012 13:20:55 UTC+2, Mark Murphy (a Commons Guy) a > écrit : > >> On Tue, Jul 3, 2012 at 7:16 AM, jean-francois garreau >> <jean.francois.garreau@gmail.**com <[email protected]>> >> wrote: >> > I already saw that presentation and I can't use the ViewHolder pattern >> > because i need a customView. >> >> That makes absolutely no sense whatsoever. >> >> - TextView inherits from View >> - ImageView inherits from View >> - CheckableTextView inherits from View >> - your custom View subclass inherits from View >> >> And: >> >> - TextView works just fine with the ViewHolder pattern >> - ImageView works just fine with the ViewHolder pattern >> - CheckableTextView works just fine with the ViewHolder pattern >> >> Hence, I am fairly comfortable that for any well-written custom View >> subclass, the ViewHolder pattern can apply. There should be nothing >> magic about your particular subclass of View compared to any other. >> >> -- >> Mark Murphy (a Commons Guy) >> http://commonsware.com | http://github.com/commonsguy >> http://commonsware.com/blog | http://twitter.com/commonsguy >> >> _The Busy Coder's Guide to Android Development_ Version 3.7 Available! >> > -- > 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 > -- Daniel Drozdzewski -- 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

