You're correct, use 0 if you need a "null" resource ID. From
http://developer.android.com/reference/android/content/res/Resources.html#getIdentifier(java.lang.String,+java.lang.String,+java.lang.String):

"0 is not a valid resource ID"

String

On Sep 15, 8:57 pm, DanH <[email protected]> wrote:
> The other thing you could do is define a resource symbol and reserve
> it for "null".
>
> But I'm almost positive that zero is "reserved" already and can serve
> as null, and I strongly doubt that a valid resource id would ever be
> negative.
>
> On Sep 15, 2:29 pm, Mark Carter <[email protected]> wrote:
>
>
>
> > Is it possible that a resource id (such as a generated id for a string
> > resource) can be a negative int?
>
> > Often, when defining a method that accepts a resource id, I want the
> > caller to be able to specify a "null" value. For primitives this is
> > not possible, but I'm wondering whether "any negative value" may be a
> > good approach?
>
> > Alternatively I suppose it would be OK to specify the argument as an
> > Integer and take advantage of auto-boxing.
>
> > Thoughts?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to