Unfortunately myfirstproject stopped working error in java
<p>I know this is a very simple question for you experts,but please forgive me.Im very new to this android platform.</p>

<p>I tried to display a string in a textview when a button is clicked.</p>

<p>But it is not working.No errors are showing.</p>

<p>Can you please help me with where im going wrong.</p>

<p>Thanks in advace.</p>

<p>Below is the code i wrote:</p>

<pre><code>package com.mycmpny.namebtn;

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

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

    public void onClick(View view){
        printmyname();
    }
    private void printmyname(){
        txtView.setText("This is my first app");
    }
}
</code></pre>
