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. User selectable text in WebView

Hi, I am using a WebView to display some text. I want to allow the
users to be able to select a word (or even a character) and take some
action on it (for example, look up the dictionary).

So far, I have only found the following code that can enable text
selection in a WebView:

KeyEvent shiftPressEvent = new
KeyEvent(0,0,KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
shiftPressEvent.dispatch(myWebView);

The above code will trigger the text selection mode in a WebView and
copy the selected text automatically into the clipboard. However, I
have no idea how I can act on the selected text when it is copied into
the clipboard. Any ideas on how I can detect that some text is copied
into the clipboard and act on it (without user interaction)?

If not, are there any other ways that I can allow users to select a
character/word in the WebView and perform some operation on it?

Thank you for your ideas.

-- 

2. Reg: retrieving the phone number on an incoming call

Hello,
        Does somebody have an example or sample code for retrieving the
phone number on an incoming phone call.

Appreciate your help

-- Adonis

-- 

3. Elevating/Adding permissions by way of first uninstalling rather than updating an app

4. Filtering based on fpu

5. I'm stuck and need some help with touchable widgets

6. ViewGroup with round angle

7. how to capture more than 2 Views?