Is there a way to copy a linear layout from xaml file and add it to the main activity?

So I have a xaml layout that has a colored linear layout with some text/buttons in it.
Can I copy it to the main activity layout a couple of times?

Best Answers

Answers

  • CortezCortez USMember ✭✭✭

    Yes, you can actually do that, but what does "a couple of times" mean? This linear layout's content is always the same?

    If yes you can place in it a ListView with an Adapter for example if you want to handle persons. You can add the person to a dataset and the ListView will represent it. In the text you show the name and with the buttons you can delete it or modify.

    If no you have to place the LinearLayouts. Maybe you can create a generator that dinamically generates the form. For example there is a form where the person can set the profile (Name, Age, Sex, etc.). Every content is different.

  • KrestekKrestek USMember ✭✭

    Well I meant a couple of times because I don't want it to be added once like a fragment to a tablayout. It's like a form of post, so each linear layout is a post that contains a title, text, likes, etc. I'm trying to make the design in axml and then everytime I want to add a post, add a copy of that axml layout and add it to the main activity layout, and then change the title, text, etc. I don't think a ListView could do what I intend to do, but I could be wrong ,_,

  • KrestekKrestek USMember ✭✭

    So I'll add views to a ListView or a similar object that is fullscreen, and I'll do my edits to the linear layouts initially, and will leave the title/text/likes/etc to the adapter.
    Thank you!

  • KrestekKrestek USMember ✭✭

    Aaaaah got it so I'll make the custom layout in the ListView, and the Post class that has the fields required. Then I'll just add items to the list, awesome :smiley:

Sign In or Register to comment.