[android-developers] Re: getDrawable() Resourses$NotFoundException
you should get the resource of your project. so, instead of using Resource.getSystem(), please use getResource().getDrawable(id) of context class. then , all right dow Eric Crump於 2010年1月14日星期四UTC+8上午9時59分30秒寫道: > > I'm trying to set a resourse in the onTable method of my map overlay. > It throws a Resourses$NotFoundException. I've also tried making it a > class variable and setting it from the MapView but I get the same > result. > > @Override > public boolean onTap(GeoPoint gp, MapView mv) > { > OverlayItem item = new OverlayItem(gp, "", ""); > Drawable drawable = Resources.getSystem().getDrawable > (R.drawable.target); > item.setMarker(altDrawable); > addOverlay(item); > return true; > } > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: getDrawable() Resourses$NotFoundException
You can use mapView.getContext().getResources().getDrawable(...) in any function that hands you the mapview you're working with. - TreKing - Chicago transit tracking app for Android-powered devices http://sites.google.com/site/rezmobileapps/treking On Wed, Jan 13, 2010 at 10:27 PM, Eric Crump wrote: > Passing it in in the constuctor will work for having an addition > Drawable, but what if I want to determine the one to pick at runtime > and there are many to choose from? > > On Jan 13, 11:11 pm, Lance Nanek wrote: > > Let's say the package name for your app is "com.example". You are > > using a value from the "com.example.R" class. The only values that > > will work with the system resources are from the "android.R" class. > > These values are not the actual content. They are just a value used to > > lookup the actual content. > > > > Have you checked out the MapView tutorial yet? It's here: > http://developer.android.com/intl/fr/guide/tutorials/views/hello-mapv... > > > > There's a good example there of passing a Drawable from the Activity > > to an Overlay via means of the constructor. > > > > On Jan 13, 9:50 pm, Eric Crump wrote: > > > > > > > > > OK. I'm not in an Activity though, I'm in the overlay class. You > > > can't call getResources() from there. Also, I printed the resource id > > > to the log to verify that there is an actual value there. It matches > > > the one in the R file. > > > > > On Jan 13, 9:47 pm, Lance Nanek wrote: > > > > > > I don't see any field named target in android.R.drawable. Are you > sure > > > > there is a system drawable resource with that name? > > > > > > If you are using your own package's R class, then you should be using > > > > your activity's resources. They are available via getResources() on > > > > the activity. Resources.getSystem() is for system resources. > > > > > > On Jan 13, 8:59 pm, Eric Crump wrote: > > > > > > > I'm trying to set a resourse in the onTable method of my map > overlay. > > > > > It throws a Resourses$NotFoundException. I've also tried making it > a > > > > > class variable and setting it from the MapView but I get the same > > > > > result. > > > > > > > @Override > > > > > public boolean onTap(GeoPoint gp, MapView mv) > > > > > { > > > > > OverlayItem item = new OverlayItem(gp, "", ""); > > > > > Drawable drawable = Resources.getSystem().getDrawable > > > > > (R.drawable.target); > > > > > item.setMarker(altDrawable); > > > > > addOverlay(item); > > > > > return true; > > > > > > > }- Hide quoted text - > > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text - > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: getDrawable() Resourses$NotFoundException
Passing it in in the constuctor will work for having an addition Drawable, but what if I want to determine the one to pick at runtime and there are many to choose from? On Jan 13, 11:11 pm, Lance Nanek wrote: > Let's say the package name for your app is "com.example". You are > using a value from the "com.example.R" class. The only values that > will work with the system resources are from the "android.R" class. > These values are not the actual content. They are just a value used to > lookup the actual content. > > Have you checked out the MapView tutorial yet? It's > here:http://developer.android.com/intl/fr/guide/tutorials/views/hello-mapv... > > There's a good example there of passing a Drawable from the Activity > to an Overlay via means of the constructor. > > On Jan 13, 9:50 pm, Eric Crump wrote: > > > > > OK. I'm not in an Activity though, I'm in the overlay class. You > > can't call getResources() from there. Also, I printed the resource id > > to the log to verify that there is an actual value there. It matches > > the one in the R file. > > > On Jan 13, 9:47 pm, Lance Nanek wrote: > > > > I don't see any field named target in android.R.drawable. Are you sure > > > there is a system drawable resource with that name? > > > > If you are using your own package's R class, then you should be using > > > your activity's resources. They are available via getResources() on > > > the activity. Resources.getSystem() is for system resources. > > > > On Jan 13, 8:59 pm, Eric Crump wrote: > > > > > I'm trying to set a resourse in the onTable method of my map overlay. > > > > It throws a Resourses$NotFoundException. I've also tried making it a > > > > class variable and setting it from the MapView but I get the same > > > > result. > > > > > @Override > > > > public boolean onTap(GeoPoint gp, MapView mv) > > > > { > > > > OverlayItem item = new OverlayItem(gp, "", ""); > > > > Drawable drawable = Resources.getSystem().getDrawable > > > > (R.drawable.target); > > > > item.setMarker(altDrawable); > > > > addOverlay(item); > > > > return true; > > > > > }- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: getDrawable() Resourses$NotFoundException
Let's say the package name for your app is "com.example". You are using a value from the "com.example.R" class. The only values that will work with the system resources are from the "android.R" class. These values are not the actual content. They are just a value used to lookup the actual content. Have you checked out the MapView tutorial yet? It's here: http://developer.android.com/intl/fr/guide/tutorials/views/hello-mapview.html There's a good example there of passing a Drawable from the Activity to an Overlay via means of the constructor. On Jan 13, 9:50 pm, Eric Crump wrote: > OK. I'm not in an Activity though, I'm in the overlay class. You > can't call getResources() from there. Also, I printed the resource id > to the log to verify that there is an actual value there. It matches > the one in the R file. > > On Jan 13, 9:47 pm, Lance Nanek wrote: > > > I don't see any field named target in android.R.drawable. Are you sure > > there is a system drawable resource with that name? > > > If you are using your own package's R class, then you should be using > > your activity's resources. They are available via getResources() on > > the activity. Resources.getSystem() is for system resources. > > > On Jan 13, 8:59 pm, Eric Crump wrote: > > > > I'm trying to set a resourse in the onTable method of my map overlay. > > > It throws a Resourses$NotFoundException. I've also tried making it a > > > class variable and setting it from the MapView but I get the same > > > result. > > > > @Override > > > public boolean onTap(GeoPoint gp, MapView mv) > > > { > > > OverlayItem item = new OverlayItem(gp, "", ""); > > > Drawable drawable = Resources.getSystem().getDrawable > > > (R.drawable.target); > > > item.setMarker(altDrawable); > > > addOverlay(item); > > > return true; > > > > }- Hide quoted text - > > > - Show quoted text - > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: getDrawable() Resourses$NotFoundException
OK. I'm not in an Activity though, I'm in the overlay class. You can't call getResources() from there. Also, I printed the resource id to the log to verify that there is an actual value there. It matches the one in the R file. On Jan 13, 9:47 pm, Lance Nanek wrote: > I don't see any field named target in android.R.drawable. Are you sure > there is a system drawable resource with that name? > > If you are using your own package's R class, then you should be using > your activity's resources. They are available via getResources() on > the activity. Resources.getSystem() is for system resources. > > On Jan 13, 8:59 pm, Eric Crump wrote: > > > > > I'm trying to set a resourse in the onTable method of my map overlay. > > It throws a Resourses$NotFoundException. I've also tried making it a > > class variable and setting it from the MapView but I get the same > > result. > > > @Override > > public boolean onTap(GeoPoint gp, MapView mv) > > { > > OverlayItem item = new OverlayItem(gp, "", ""); > > Drawable drawable = Resources.getSystem().getDrawable > > (R.drawable.target); > > item.setMarker(altDrawable); > > addOverlay(item); > > return true; > > > }- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: getDrawable() Resourses$NotFoundException
I don't see any field named target in android.R.drawable. Are you sure there is a system drawable resource with that name? If you are using your own package's R class, then you should be using your activity's resources. They are available via getResources() on the activity. Resources.getSystem() is for system resources. On Jan 13, 8:59 pm, Eric Crump wrote: > I'm trying to set a resourse in the onTable method of my map overlay. > It throws a Resourses$NotFoundException. I've also tried making it a > class variable and setting it from the MapView but I get the same > result. > > @Override > public boolean onTap(GeoPoint gp, MapView mv) > { > OverlayItem item = new OverlayItem(gp, "", ""); > Drawable drawable = Resources.getSystem().getDrawable > (R.drawable.target); > item.setMarker(altDrawable); > addOverlay(item); > return true; > > } > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en