How to Use String as a ResourceID in Android

前端 未结 1 633
Happy的楠姐
Happy的楠姐 2021-01-22 11:57

I\'ve several TextViews or another component, doesn\'t matter. And the views have iteration ids like: textView1, textView2, textView3 etc.

Simp

1条回答
  •  无人及你
    2021-01-22 11:59

    You can use Resources#getIdentifier() to get the identifier from a string.

    But if you are going to iterate over them, wouldn't it be easier to keep the ids in an array or a list?

    0 讨论(0)
提交回复
热议问题