I have a problem with ids on Java for Android. I do some TextView by code, and give it an id. But I can't get the TextView with the id I gave it.
I tried to do this, but it's wont work.
LinearLayout ll;
int id = 2000000;
private void init() {
ll = findViewById(R.id.layout);
}
private TextView addTV(int x, int y, int width, int height) {
TextView tv = new TextView(this);
tv.setId(id);
id++;
tv.setText("Hello");
return tv;
}
private void changeTextTV(int id, String text) {
TextView tv = findViewById(id); //<- this is wrong, but I don't know what is right
tv.setText(text);
}
init();
ll.addView(addTV(0,0,100,100));
changeTextTV(2000000, "It's me");
Could you help me ?
PS : I'm French, so sorry for my spelling mistakes