Why isn't this simple program working?
Posted
by
user1445478
on Stack Overflow
See other posts from Stack Overflow
or by user1445478
Published on 2012-06-08T22:24:15Z
Indexed on
2012/06/08
22:40 UTC
Read the original article
Hit count: 188
I'm writing a very basic program that aims for the text view to display the phrase "Hello" after a button is pressed on the screen. However, I can't get this program to work; every time I run it, it says that the application has stopped unexpectedly. This is the program I wrote:
public class EtudeActivityActivity extends Activity{
TextView tvResponse;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final TextView tvResponse = (TextView) findViewById (R.id.tvResponse);
}
public void updateTV(View v) {
tvResponse.setText("Hello");
}
}
Also, I inserted an android:onClick = "updateTV"
into my main.xml file for the button.
Thanks for any help!
© Stack Overflow or respective owner