i have been stuck on this problem for far too long. i think it's simple but i'm a newbie android developer so your help would be greatly appreciated.
i have two activities. my main activity layout has a textview and a button. What i am trying to do is to implement the button to change the text of the textview from another activity class (Btn class).
this is my Btn class
public class Btn extends Activity implements OnClickListener {
Button btn;
TextView textBox;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button) findViewById(R.id.btn);
textBox = (TextView)findViewById(R.id.address);
btn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
textBox.setText("Test Test");
}
}
now this compiles and works fine but when i press the button nothing happens. i would like to know how change the text of the textview when i press the button. i know how to do this in my main activity class but i would like to do it from another class.