Toast - I can't get it to work in Eclipse...

by furby » Wed, 04 Nov 2009 23:33:04 GMT


Sponsored Links
 So I am slowly trying to figure out maps... I want to be able to click
on a point and pop up a message. Toast seemed the way to go. So I
added an "onTap" handler in my class that extends ItemizedOverlay (the
class is called HelloItemizedOverlay) and then tried to grab the Toast
example... But I am seeing Eclipse tell me that the line is in error
no matter what I do... My code is below - could someone tell me what i
am doing wrong?

protected boolean onTap(int index) {
        Toast.makeText(HelloItemizedOverlay.this, "TEST",
Toast.LENGTH_SHORT).show();
        return super.onTap(index);
}

--



Toast - I can't get it to work in Eclipse...

by Mark Murphy » Wed, 04 Nov 2009 23:38:32 GMT


 


And the error Eclipse gives you is...what?

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

App Widgets Deep Dive Seminar, 27 January 2010:  http://bit.ly/deepdive 

--


Sponsored Links


Toast - I can't get it to work in Eclipse...

by furby » Wed, 04 Nov 2009 23:52:52 GMT


 It underlines the "makeText" word and when I ask it for suggestions
all it says is "Rename in file".....

Which makes me wonder if, perhaps, "makeText' no longer exists in the
Toast object?






--



Toast - I can't get it to work in Eclipse...

by furby » Wed, 04 Nov 2009 23:59:42 GMT


 To be sure that you have some idea of what I am talking about, here is
the code for the entire class :

import java.util.ArrayList;

import android.graphics.drawable.Drawable;
import android.widget.Toast;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class HelloItemizedOverlay extends ItemizedOverlay {
        private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>
();

        public HelloItemizedOverlay(Drawable defaultMarker) {
                super(boundCenterBottom(defaultMarker));
        }

        @Override
        protected OverlayItem createItem(int i) {
          return mOverlays.get(i);
        }


        @Override
        public int size() {
                return mOverlays.size();
        }

        public void addOverlay(OverlayItem overlay) {
            mOverlays.add(overlay);
            populate();
        }

        protected boolean onTap(int index) {
                Toast.makeText(HelloItemizedOverlay.this, "TEST",
Toast.LENGTH_SHORT).show();
        return super.onTap(index);
   }
}







--



Toast - I can't get it to work in Eclipse...

by furby » Thu, 05 Nov 2009 00:42:15 GMT


 Hmmm.... Am I putting the onTap handler in the wrong place? I thought
that it would go in the overlay handler....






--



Toast - I can't get it to work in Eclipse...

by FFEH » Thu, 05 Nov 2009 00:51:46 GMT


 Maybe you can try to use Toast.LENGTH_LONG




>



Toast - I can't get it to work in Eclipse...

by furby » Thu, 05 Nov 2009 01:06:10 GMT


 Perhaps I am going about this the wrong way... it seems like a lot of
shifting of code around to get a simple message to display in google
maps.

Let me rephrase the question : Is there a simple way to get the two
String parameters to display (That are sent to the OverlayItem class)
when a point is clicked on? I would assume that google maps woudl have
somethign built in (I am used to using maps in Javascript where it's
pretty much just a onClick event handler...).

You must remember - when it comes to this you can treat me like a
complete idiot - I am starting from the basics of this topic... The
Google "Hello Views" tutorial for maps got me this far but neglected
to explain how to handle a click on a point....






--



Toast - I can't get it to work in Eclipse...

by furby » Thu, 05 Nov 2009 01:22:11 GMT


 Thank you! The got my app to display a message to the user! Yay!

And you are about to have a customer!






--



Other Threads

1. How to clear a notification when using a PendingIntent?

You need to specify the FLAG_AUTO_CANCEL in the Notification.flags field:
http://code.google.com/android/reference/android/app/Notification.html#FLAG_AUTO_CANCEL

Christoph





--~--~---------~--~----~------------~-------~--~----~

2. in-memory live object histogram

Hi,

Is there a way of querying Android (or G1 or DDMS) for a list of all
currently live objects
by type and by nymber of instances.

That is:
   - your app currently have 122 objects of type MyClass
   - your app currently have 201 objects of type MyOtherClass

etc.

Makes memory leak debugging much simpler!

Pls note that DDMS's Allocation Tracker is not what I'm looking for,
as it does not
allow creation of such type-based histograms.

Tnx,
GiladH


--~--~---------~--~----~------------~-------~--~----~

3. GUI screen builder for android apps

4. can't kill dhcpcd completely?

5. ADP1 users, how to really get updates

6. I am getting NullPointer exception for my app when switching from potrait mode to landscape mode and vice versa

7. Graphics question: bilinear interpolation