Clone textview to append it to a ViewGroup

前端 未结 3 1103
心在旅途
心在旅途 2020-12-20 12:29

I have a ViewGroup defined in XML with a view inside, at onCreate time I\'d like to have a variable of those.
I don\'t want to go through the hassle of using a listview+

3条回答
  •  粉色の甜心
    2020-12-20 13:08

    Maybe use an inflater, and put the textview in an external layout file:

    View v = LayoutInflater.from(this).inflate(R.layout.textview_include, null);
    viewGroup.addView(v);
    

提交回复
热议问题