I knew there was something that I missed.  Thanks to all who shed
light on this thread.  Here's the final code for those newbies who may
have the same problem.

package com.HelloWorld;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class Hello extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        // start code here

        // declare tv object by findViewByID
        final TextView tv = (TextView) findViewById(R.id.TextView01);

        // set TextView's text property to a new string upon launch of
app
        tv.setText("This is sample.");

        // declare button object by findViewByID
        Button button = (Button) findViewById(R.id.Button01);

        // Method if you click the button
        button.setOnClickListener(new OnClickListener() {
                        public void onClick(View v) {
                                // this is a pop up message then goes away 
after a short period of
time
                                Toast.makeText(Hello.this, "Hello World",
Toast.LENGTH_SHORT).show();

                                // this changes the text in the TextView object 
to the said string
                                tv.setText("Button Clicked");
                        }
        });
    }
}


On Sep 1, 2:26 am, Filip Havlicek <havlicek.fi...@gmail.com> wrote:
> You still need to specify the tv variable type (of course, think about
> it!!!).
>
> TextView tv = (TextView) findViewById(R.id.TextView01);
>
> Best regards,
> Filip Havlicek
>
> 2010/9/1 rb <rbs...@gmail.com>
>

-- 
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

Reply via email to