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

by Mark Murphy » Thu, 05 Nov 2009 00:02:01 GMT


Sponsored Links
 


The first parameter to makeText() needs to be a Context, such as an
Activity.

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

_Android Programming Tutorials_ Version 1.0 Available!

--



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

by Mark Murphy » Thu, 05 Nov 2009 00:57:25 GMT


 


Your onTap() is in the correct place. However, HelloItemizedOverlay is
not a Context, and so it cannot be used as the first parameter to
makeText().

Either make HelloItemizedOverlay an inner class of your MapActivity, or
pass the MapActivity as a parameter to the HelloItemizedOverlay
constructor, or something, then use that object as the first parameter
to makeText().

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

Android Consulting/App Development:  http://commonsware.com/consulting 

--


Sponsored Links


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

by Mark Murphy » Thu, 05 Nov 2009 01:15:04 GMT


 


Not really.


You are using the simple way. You just have the wrong type for the first
parameter to the makeText() method. It would similarly fail if you tried
passing an integer for the first parameter, or a boolean.

You can see an example of using a Toast from an ItemizedOverlay in one
of my book examples. I don't have these examples up on github just yet
(probably this weekend), so I can't directly link to it. For now, visit:

 http://commonsware.com/Android/ 

Scroll down and click on the Source Code link opposite the table of
contents. In the ZIP file, you will see Maps/NooYawk/. Look for the
onTap() implementation there.

Since my ItemizedOverlay is an inner class of my MapActivity, I already
have access to a suitable Context to provide to makeText().

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

Android Development Wiki:  http://wiki.andmob.org 

--



Other Threads

1. Image cropping in SDK 1.1

Hi, I am not able to find any API for cropping images in the latest
android SDK. Can someone please tell me where should I look for. Also
is there a way to use the Pictures application in Android to crop
images i.e. calling that activity from my activity.

Any help would be appreciated.


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

2. R class not created or updating in Eclipe

Hi,

I recently installed and got started with the android SDK. After
setting up the SDK and the Eclipse ADT plugin I ran the API Demo's
project fine. When trying to create my own HelloWorld project I
noticed that the R class was not auto created. After some searching I
found that the problem was not local to me, yet a solution wasn't
presented. Is this a bug? Intended? Is there a workaround?


Thanks,
Mike

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

3. need help in getting screen coordinates of a view

4. Android SDK for 64 bit Linux?

5. g1 version

6. how do i get the center location after a user dragged their center point to another location on a map?

7. how to get the new center location on a map after user had dragged it?