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. Android WebView Protocol Handler

Hello Android developers.

I want to implement a custom protocol handler which will handle all
request to some protocol in a WebView.

For example, it could handle requests like myprotocol://image5.jpg
which would be requested if a <image src="myprotocol://image5.jpg"/>
was in the html given to the WebView.

I have read this post about the problem:

2. Application Object and Intents

I have an application that I am developing where I am sending an
intent from the Application class.  The intent has extras, and I am
using sendBroadcast.  Everytime I try and send the intent I get a
nullreferencepointer exception.  I have tried sending it from my
onDecodedData method as well as from another method that is called by
onDecodedData.  Now I am trying to call it from a class that extends
broadcast receiver.  Nothing is working.  Here is my code for sending
the intent:

public void onDecodedData(DeviceInfo deviceInfo,
                                ISktScanDecodedData decodedData) {
                        // Log.d(TAG, "Received Scan");
                        // if(_scanwindow!=null)
                        char[] data = decodedData.getData();
                        String processedData = processData(data);
                        Log.d(TAG, "Received Scan = " + processedData);
                        // Intent intentsent = new Intent(
                        // PickupItemsActivity.NOTIFY_DATA_ARRIVAL);
                        // Intent intentsent = new Intent();
                        // char[] data = decodedData.getData();
                        // processedData);
                        // String symbologyName = 
                        // symbologyName);
                        try {
                                // sendScanData(processedData);
                                new SendIntents().sendIntent(processedData);
                                Log.d(TAG, "Scan Intent Sent");
                        } catch (Exception e) {
                                Log.d(TAG, "Error = " + e.getMessage());

private class SendIntents extends BroadcastReceiver {
                ProgressDialog dialog;

                public void onReceive(Context arg0, Intent arg1) {
                        // TODO Auto-generated method stub


                public void sendIntent(String msg) {
                        /*Intent intentsent = new Intent(
.putExtra("", msg);
                        sendBroadcast(new Intent(
                        Log.d(TAG, "Sending Intent Sent");



3. How to use ListView in Tab?

4. Multiple Sliding Drawers in a ListView

5. Manually Dispatch Key Event

6. Sync contact

7. To know how emailprovider.db gets populated