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. FB errot

As subject, kenapa ya skrg2 ini kok kalo gw buka friend request tampil
halaman denied gtuh, ada yg mengalami hal serupa?

Need help please...

-- 
"Indonesian Android Community [id-android]" 

2. Multiple Gallery Widgets won't scroll

Does anyone have any solution for placing multiple Galleries on a
layout? The problem is only one Gallery will scroll with multiple
Galleries on a layout. The other Galleries won't work. Anyone know a
workaround ?

Thanks

-- 

3. Intent.ACTION_SYNC no docs or resolveInfo

4. Paging oom Alex Bong

5. Lauterbach source level debugging in android

6. How to download android source code in windows machine

7. Bantuin nge-root