displaying a string on the textview when clicking a button in android
<p>Im very new to this android development and just started to study.So sorry for this simple question.</p>

<p>What i trying is to add a button and when that button is pressed a text "my first project" to get displayed in the text view.</p>

<p>With the help of some experts i created the button and text view.</p>

<p>so the button is showing in the simulator but when i click that button nothing happens.</p>

<p>Can anyone please help me with how can i display the text when pressing the button.</p>

<p>.xml</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" &gt;

    &lt;TextView
        android:id="@+id/txtView"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:text="@string/hello" /&gt;

    &lt;Button
   android:id="@+id/mybtn"
   android:layout_width="50dp"
   android:layout_height="30dp"       /&gt;
    &lt;TextView
   android:id="@+id/viewwidth"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"     /&gt;
&lt;TextView
   android:id="@+id/viewheight"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"    /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>.java</p>

<pre><code>import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.view.View;
import android.widget.Toast;

public class NameonbuttonclickActivity extends Activity implements View.OnClickListener {
    Button mybtn;
    TextView txtView;
    String hello;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.main);
        super.onCreate(savedInstanceState);
        mybtn= new Button(this);
        txtView=new TextView(this);
        mybtn.setOnClickListener(this);
        printmyname();

        mybtn = (Button)findViewById(R.id.mybtn);
        txtView=(TextView)findViewById(R.id.txtView);
        txtView = (TextView)findViewById(R.id.viewwidth);
        txtView = (TextView)findViewById(R.id.viewheight);

        hello="This is my first project";

        //setContentView(mybtn);
       // setContentView(R.layout.main);
    }

    public void onClick(View view){
        txtView.setText(hello);         

    //printmyname();
     Toast.makeText(NameonbuttonclickActivity.this, hello, Toast.LENGTH_LONG).show();               

    }            
    private void printmyname(){
        System.out.println("coming");       

    }
}
</code></pre>

<p>hoping for your help.Thanks in advance.</p>
