Button and TextView in android not working
<p>the following program force quit and crashes, I don't understand why,</p>

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

public class MainActivity extends Activity {
    /** Called when the activity is first created. */

    TextView tv = (TextView) findViewById(R.id.text);
    Button btn1 = (Button) findViewById(R.id.button1);

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    public void clicked(View v) {

        tv.setText(btn1.getText());
    }
}
</code></pre>

<p>but after moving the </p>

<pre><code>TextView tv = (TextView) findViewById(R.id.text);
Button btn1 = (Button) findViewById(R.id.button1);
</code></pre>

<p>inside the clicked function it works, why is that?</p>

<p>thanks for any help..</p>
