Can someone explain me why this code doesn’t work? I want to change the text of the textview with Java code but nothing changes.
package com.example.gethtml;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
GetCode getCode = new GetCode();
Affiche affiche = new Affiche();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
getCode.getCode();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Code to change the
textview‘s text through java code should contain at least oneTextViewobject to start with. I can not see that in your code. But I am writing below a sample code for that.Your
activity_main.xmlshould containTextViewdefined with id you are referring. Hope it helps.