How to get Position of an view added dynamically on LinearLayout

前端 未结 4 1093
庸人自扰
庸人自扰 2020-12-12 00:39

I need to get an dynamically added view position in LinearLayout with vertical orientation. For example i have 4 TextViews added dynamically on LinearLayout, then i need to

4条回答
  •  再見小時候
    2020-12-12 01:19

    I see following options:

    • Declare some id's in resources in form of first and assign them to views in adding to layout, after that use normal findViewById() mechanism
    • Assign some tags to views you're adding to a layout via setTag method and after that use findViewWithTag mechanism
    • Remeber position of your views and use them vie getChildAt method

提交回复
热议问题