Skip object in BasicAdapter / CustomListAdapter

by 艁ukasz Warcho艂 » Fri, 27 Feb 2009 21:42:39 GMT

Sponsored Links
 Hi all,
I have my own ListAdapter  drawing my list. But i have a question. Is it 
possible to skip(not draw) object?
For example: I have a ArrayList with things to draw, and dont wanto to 
draw one at positon 2. Anyone nows how to?


Skip object in BasicAdapter / CustomListAdapter

by Mark Murphy » Fri, 27 Feb 2009 21:47:15 GMT


Expanding on your example, let us assume you have a six-item list, and
you do not want to draw the one at position 2 -- you only want to draw
positions 0, 1, 3, 4, and 5.

You would need to override getCount(), getItem(), and every other
Adapter method that knows about the number and positions of objects. You
would have getCount() return 5 instead of 6 (since you are only drawing
5) and have getItem(), getView(), etc. know to subtract 1 from the
supplied position if the supplied position > 2.

It would be far simpler to just remove the offending item from the list
in the first place, if possible.

Mark Murphy (a Commons Guy) 
_The Busy Coder's Guide to Android Development_ Version 2.0 Published!


Sponsored Links

Skip object in BasicAdapter / CustomListAdapter

by 艁ukasz Warcho艂 » Fri, 27 Feb 2009 21:50:28 GMT

 Yeah, i was thinking about deleting it from the list, but i thought taht 
there is any way of returning null from GetView(). Ok I think i'll 
delele this file form list. Thanks

Mark Murphy pisze:


Other Threads

1. Froyo -- How to detect that my application has been killed?

Applications can't kill services with this.  They can only kill background
processes, which the OOM killer is free to kill at any time anyway.

On Thu, Jul 29, 2010 at 6:37 PM, <


2. Plug for "Beginning Android 2"

Having been in software development for 40+ years, this is about the 
ump{*filter*}th operating system/language that I've had to learn, and I always 
find it best to read about a new one to the point where I have a good 
understanding of the terminology and how the pieces fit together. Once I 
have that nailed, using the reference docs becomes a lot easier.

For that purpose, I would highly recommend "Beginning Android 2" by some guy named Mark Murphy who shows up in these forums on occasion :-). I'll admit that I was initially a bit put off when looking at the table of contents on Amazon because of the cutesy bad-pun section headings -- I was not looking for "Android for Dummies!" However, I went ahead an purchased it based on some other recommendations and have found it to be exactly what I was looking for: a straightforward, logical presentation of the basic features of the Android system, with concise sample code examples to illustrate them. This was certainly not enough for me to develop the somewhat complex application that I have in mind, but it certainly sets me on the right path to begin my design, and lets me know in what sections of the reference material to look for more of the{*filter*}details. I'd definitely recommend this book to any beginners, as it certainly answers a lot of the basic questions that I see being asked here in this forum. Doug Gordon GHCS Software --

3. How to populate a ViewFlipper child view with a ListView??

4. JNI System.loadLibrary() not needed?

5. How to populate a ViewFlipper child view with a ListView??

6. Interaction between an Activity and a Service ?

7. ATTENTION: Android-Beginners will be permanently disabled on August 9 2010