My app crash if I use findViewById in other class than MainActivity
<p>I need to use the method setText() to write text in a TextView.
If i write this     </p>

<pre><code>TextView t = (TextView)this.findViewById(R.id.test);
</code></pre>

<p>in my MainActivity class it works, if i try writing it in another class, for example here</p>

<pre><code>public class AssociaCarta extends Activity{
    public void associaCarta(int numeroRandom, ImageView carta) {   
        TextView t = (TextView)this.findViewById(R.id.test);
    }
}
</code></pre>

<p>my app crashes.
I don't understand why.</p>
