Setting Button ID programmatically

前端 未结 6 1398
慢半拍i
慢半拍i 2021-01-01 04:10

Android 2.3.3

I have a table with N rows and N columns. For each row, I should add 4 buttons dynamically, and later do actions based on the button clicked. I know we

6条回答
  •  北荒
    北荒 (楼主)
    2021-01-01 04:46

    If you have the references to the views anyway , you can simply save them all into a HashMap, for example using HashMap .

    Another alternative , so that you will avoid any typos , is to have an enum as the key of the hashMap , for example : HashMap .

提交回复
热议问题