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. How to know whether a table already exist in database?

Hello, everyone
  Before I create a table, how can I know whether the table already exist in
database? How to query?
  Thanks.

Best wishes.
Fion

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

2. Strange Layout Bug

Hi,

i have a very strange Layout bug.

I have a TableLayout
 where are three other TableLayouts included
I needed TableLayou because of the autostretch.

anyhow, First Time i had the problem that the buttonsText in the first
table disappeared
when i pressed em.
I solved it while i made a relative layout out of the first table.

NOW: i have the strange problem always when my gesturedetection starts
my redraw
of the layout the buttons in the last table loose there Gravity
(before center and than suddently left)

I guess its some memory problem or i dont know.

FUNNY !! when I start and open, before ich do a gesture on the screen,
a dialog and close that again.
my layout keeps stable?!!!

Any Ideas ????

Greets
Chris

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

3. Finish all previous Activities?

4. InsetDrawable inside LayerDrawable

5. Cached Background Bitmaps From Widgets?

6. Sqlite Paging Results

7. In-call audio / media access