Dynamically adding a child to LinearLayout with getting each child's position

前端 未结 2 1955
我在风中等你
我在风中等你 2021-01-02 08:11

I have a problem with getting the child\'s position of LinearLayout. First I\'m adding dynamically a number of buttons and then I\'m trying to return each child\'s

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-02 08:40

    You must setContentView before start findViewById

    setContentView(R.layout.main);
    tv = (TextView) findViewById(R.id.text);
    

提交回复
热议问题