How to programmatically add an ID to the textview?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
11 views
Good day to all. Tell me, when we do the layout, then write this:



Well. And now we can refer to the TextView using its id.

How to programmatically add an id for this TextView?

Do:

textView.setId(i);

where i is Int. In this case, everything works fine. But if you try to add this:

textView.setId(Integer.valueOf(string));

then the app crashes.

Why in the markup we can use a literal value id, and the software no?
by | 11 views

1 Answer

0 like 0 dislike
Why in the markup we can use a literal value id, and the software no?

Because "alpha" is a variable of type int (R. id.your_id)
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,796 users