As Havlicek said, create the textview using findViewByID and set the
text when button is clicked.

Sample code:

tv = (TextView) findViewById(R.id.TextView01);
tv.setText("This is sample.");
Button button = (Button) findViewById(R.id.Button01);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
        tv.setText("Button Clicked");
}
});






On Aug 31, 4:59 am, parag <[email protected]> wrote:
> Any suggestions on why I am getting the "false" reading --> in the
> xml , set the button propert android:clickable"   as true,
>
>  anyone
> can suggest on how to place the results in a TextView via a button
> click, that would be appreciated.
>
> as i can c u have the listener to the button,
> on click
> can u be specific what exact result u need?
> wether u need to change the text... etc.
> u can use
> tv.XXXXXXX specifically to change the required properties
>
> On Aug 28, 8:28 pm, rb <[email protected]> wrote:
>
>
>
> > As a newbie, I have been reading posts in learning how to do different
> > functions.  Using the Hello World example, I added a textview object
> > to this application but the results come back as false on the screen.
> > Here's my code:
>
> > main.xml:
>
> > <?xml version="1.0" encoding="utf-8"?>
>
> > <RelativeLayout android:id="@+id/RelativeLayout01"
> > android:layout_width="fill_parent" android:layout_height="fill_parent"
> > xmlns:android="http://schemas.android.com/apk/res/android";>
> >         <Button android:id="@+id/Button01"
> > android:layout_width="wrap_content"
> > android:layout_height="wrap_content" android:text="Click Me"
> > android:layout_centerInParent="true"></Button>
> >         <TextView android:text="@+id/TextView01" 
> > android:id="@+id/TextView01"
> > android:layout_below="@id/Button01"
> > android:layout_height="wrap_content"
> > android:layout_width="fill_parent"></TextView>
> > </RelativeLayout>
> > ---------------------------------------------------------------------------­­------------------------------------------------------
> > Hello.java
>
> > 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
> >         TextView tv = new TextView(this);
> >         tv.setText("This is sample.");
> >         Button button = (Button) findViewById(R.id.Button01);
> >         button.setOnClickListener(new OnClickListener() {
> >                         public void onClick(View v) {
> >                                 // TODO Auto-generated method stub
> >                                 Toast.makeText(Hello.this, "Hello World",
> > Toast.LENGTH_SHORT).show();
>
> >                         }
> >         });
> >     }
>
> > }
>
> > ---------------------------------------------------------------------------­­------------------------------------------------------
> > Note that the example included a clickable button which has a popup to
> > say "Hello World".  That works just fine, but setting the text in the
> > TextView comes out as false.  Originally I wanted to click on the
> > button and present the results in a TextView, but I was unable to do
> > that unless someone can shed some light on that.
>
> > Any suggestions on why I am getting the "false" reading and if anyone
> > can suggest on how to place the results in a TextView via a button
> > click, that would be appreciated.- 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 [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