[Solved] Java/XML – Change TextView


Code to change the textview‘s text through java code should contain at least one TextView object to start with. I can not see that in your code. But I am writing below a sample code for that.

setContentView(R.layout.activity_main);
TextView txtView = (TextView) findViewById(R.id.txtview);
txtView.setText("This is changed text");

Your activity_main.xml should contain TextView defined with id you are referring. Hope it helps.

2

solved Java/XML – Change TextView