I have a TextView whose id is toptext. I want to change the text using setText in a onSetClickListener event using the following code
public class testafrnl3 extends Activity {
private TextView menutitle;
private ImagView mmovie;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mmovie = (ImageButton) findViewById(R.id.movieSelect);
menutitle = (TextView) findViewById(R.id.toptext);
mmovie.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
menutitle.setText("Movies2");
}
}
}
R.id.toptext comes with a value of “Old Movie” from the layout. When I run this code, the textView does not change but once i carry that line of code of the onSetClickListener, it changes. Please does anyone have a solution.
Do you have the case of “toptext” correct in the code and the XML? Seems to me it should be topText based on your movieSelect (and standard conventions.) Looks perfectly fine otherwise.