ItemizedOverlay onTap setText

Tutorials that use the MapActivity. Many using GPS functionality.

ItemizedOverlay onTap setText

Postby puppetmaster » Mon Feb 16, 2009 5:06 pm

Hallo anddev community,

at first: thx for your nice communication plattform about android. And now in my first topic i allready have a question. I try to change the text from a TextView if the onTap() method from the Class ItemizedOverlay is called. Unfortunately that trows out an exception. Here you got my code-snippet

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4.         public boolean onTap(GeoPoint p, MapView mv) {
  5.  
  6.  
  7.  
  8.         OverlayItem overlayitem = new OverlayItem(p, "", "");
  9.  
  10.         addOverlay(overlayitem);
  11.  
  12.        
  13.  
  14.         TextView tv = (TextView) mv.findViewById(R.id.tv_WhereIAm);
  15.  
  16.         CharSequence cs = (CharSequence) new String("put some text in here");
  17.  
  18.         try {
  19.  
  20.             tv.setText(cs);
  21.  
  22.             Log.i("info", "OK!");
  23.  
  24.         } catch (Exception e){
  25.  
  26.                 Log.i("info", "Damn it");
  27.  
  28.         }
  29.  
  30.                 return super.onTap(p, mv);
  31.  
  32.         }      
  33.  
  34.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


The rest of the programm ist nearly simular to this example http://developer.android.com/guide/tuto ... pview.html . Perhaps the class havent the right to change the TextView? (was that a stupid thought?)

Can anybody tell me what i am doing wrong? Thanks a lot for every kind of help!
Last edited by puppetmaster on Mon Feb 16, 2009 8:43 pm, edited 1 time in total.
puppetmaster
Freshman
Freshman
 
Posts: 3
Joined: Mon Feb 16, 2009 4:48 pm

Top

Postby puppetmaster » Mon Feb 16, 2009 6:50 pm

finaly i got it!

I have to override the ItemizedOverlay constructor in myItemizedOverlay class and set a private variable for the MapActivity which has called the extended ItemizedOverlay class. If i call that class from the MapActivity i have to call it like this : itemizedOverlay = new myItemizedOverlay(this, drawable); very simple and sure a novice tipp :-) sorry for badger you!
puppetmaster
Freshman
Freshman
 
Posts: 3
Joined: Mon Feb 16, 2009 4:48 pm

Top

Return to Map Tutorials

Who is online

Users browsing this forum: Google Feedfetcher and 2 guests