_____  

From: [email protected]
[mailto:[email protected]] On Behalf Of Raymond Rodgers
Sent: Sunday, January 04, 2009 1:34 PM
To: [email protected]
Subject: [android-beginners] Re: notification


Teena wrote: 

-----Original Message-----

From: [email protected]

[mailto:[email protected]] On Behalf Of Raymond Rodgers

Sent: Sunday, January 04, 2009 11:45 AM

To: [email protected]

Subject: [android-beginners] Re: notification





Teena wrote:

  

Thanks for the response, Cyril.  Is this how I would do it?  I'm still 

not seeing any text feedback on the screen when I click the button.

  

    

Log will put strings into a log that's viewable in debug mode in Eclipse

with the Logcat view added to the overall list of views. That's very useful

for debugging purposes [obviously] without displaying anything to the app's

user. However, if you want to display something on screen, you can use the

Toast class

http://code.google.com/android/reference/android/widget/Toast.html to

display a message on screen briefly. The message will fade automatically

after a short amount of time, and could be useful for what you're trying to

accomplish.



Raymond





Thanks Raymond, I really appreciate the help.  One more question though, I'm

trying to use the toast widget properly, but cannot figure out the 'context'

that I need to put in as a parameter.  Updated code below:



package test.app;



import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.Toast;



public class test_app extends Activity {

    /** Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        /* Find the button from our XML-layout. */

        Button b = (Button)this.findViewById(R.id.btn_open_search);

        b.setOnClickListener(new OnClickListener() {

                public void onClick(View agr0) {

                        // Place code to handle button click here

                        Toast.makeText(test_app, "btn-click", 9);

                }

        });

    }

}





The error I'm getting is 'test_app' cannot be resolved, but test_app is my

activity as specified in the AndroidManifest.xml.  What am I doing wrong?





  

Instead of "test_app" use "this" in  Toast.makeText(). That's a special
pointer (ok, Java zealots, I know that's a C/C++ term, but the concept's the
same :-) ) to the object in which the function is being referenced: the
test_app object of  your application.  I really think there should be a
version of that function that doesn't require the Context parameter, so that
using "this" wouldn't be necessary, but at the moment it is required.

Raymond 


 Thanks Raymond for explaining it (now I understand, the google page with
info on toast did not have this tidbit).  And thanks for the help!  :) 

--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to