Hi,

R.string does not contain strings but int values that identify your
strings. You can use the Context and its Resource (see getResources())
to load a String given its id.

Also, you cannot retrieve the Activity by calling getParent() on a
view. An Activity is *never* the parent of a View. Only two classes
can be a View's parent in the UI framework: a ViewGroup (for instance
a LinearLayout) and ViewRoot. Note that ViewRoot is not accessible
from your application.

On Thu, Jun 19, 2008 at 9:26 AM, Fräntz Miccoli
<[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I'm trying to show an Alert to the user after he clicked over a button, but
> i think i'm not going in the right way; May someone can help me.
>
> In my listener, I've only write this dirtyCode to access to my activity in
> order to use the showAlert method :
>
> ((Activity)button.getParent().getParent().getParent()) //notes that button
> is the argument of the onclick method
>
> What is the right method to do it properly (does passing the Activity as an
> argument is the only other way ?) ?
>
> I've tried to wrote this code :
> ((Activity)button.getParent().getParent().getParent()).showAlert(R.string.login_alert_title,
>
>                1,
>
>                R.string.login_alert_message,
>
>                R.string.login_alert_button,
>
>                false);
>
> But this didn't work, Eclipse recognize my R.string.name arguments as
> String.... So i've finally wrote this :
> ((Activity)button.getParent().getParent().getParent()).showAlert(""+R.string.login_alert_title,
>
>                1,
>
>                ""+R.string.login_alert_message,
>
>                ""+R.string.login_alert_button,
>
>                false);
>
> So why does Eclipse takes me for a dummy ? My string.xml contains :
> <?xml version="1.0" encoding="utf-8"?>
> <resources>
>     <string name="app_name">MySkreen @ Androïd</string>
>     <string name="login_login">Login</string>
>     <string name="login_password">Password</string>
>     <string name="login_button">Go !</string>
>     <string name="login_alert_title">Identifiants incorrects</string>
>     <string name="login_alert_message">Vos identifiants ne sont pas
> corrects.</string>
>     <string name="login_alert_button">Ok</string>
> </resources>
>
> In my others tests this was working (recognizing String in string.xml...
>
> Hoping I was clear enough.
>
> Regards.
>
> Fräntz
>
> PS : if needed : sorry for my dreadful english.
>
> --
> Fräntz Miccoli
> +336.70.92.76.16
> [EMAIL PROTECTED]
> >
>



-- 
Romain Guy
www.curious-creature.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to