How to add a copy of XML dynamically

后端 未结 4 1245
深忆病人
深忆病人 2021-01-17 06:08

I am making an Android app, and I want to copy some XML code in a Linear Layout, and re-insert it into the Linear Layout so that there are two of the Relative Layouts in the

4条回答
  •  不思量自难忘°
    2021-01-17 06:24

    I FOR SURE got it working this time! I used this code:

     LinearLayout item = (LinearLayout)findViewById(R.id.tileContainerME);
            View child = getLayoutInflater().inflate(R.layout.activity_main, null);
            item.addView(child);
    

    It would copy the 'activity_main' class which holds solely the XML data for the tile. Then it copies it into the Horizontal Scroll View! Here is a screenshot of my solution:

    http://i.stack.imgur.com/WxoJG.png

提交回复
热议问题