I managed to have a button and then when I click on it, I go to a new activity that is called “TUTORIALONE”
and then I want to display some text in this new activity
so I have something like this
Button b = (Button) findViewById(R.id.tutorial1);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startActivity(new Intent("my.android.TUTORIALONE"));
TextView tv = (TextView)findViewById(R.id.tutorial1);
tv.setText("this is some text);
}
});
the problem is that it first displays the text on my button, and then it shows me the new activity, how would I achieve displaying the text on the new activity?
thanks in advance
In your
TUTORIALONEactivity you probably have an associated xml file for displaying content. Perhaps it iss set something like thisIn the layout xml file for
TUTORIALONEjust add something like thisEDIT
To change the text of this
TextView, do something like this in yourTUTORIALONEactivity.Note that the id here (R.id.text) is the same as in the xml file (“@+id/text”)