JoeCoolman
JoeCoolman

Reputation: 532

Replicating views in Android

I made a view which is a checklist, it has text inputs fields, checkboxes and two buttons, one for save the list and the other for delete all. Ok, but a friend (who is using my app) says "I need this for different kinds of stuff to be listed too". How can I replicate my entire view in an easy way, Should I declare this as a class and then creating several instances?. Thank you in advance.

Upvotes: 0

Views: 77

Answers (1)

Leandroid
Leandroid

Reputation: 2047

You can use the include tag.

For example, if you have your view saved as file.xml on your 'layout' folder, you can add it anywhere using this code:

<include android:id="@+id/myView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        layout="@layout/file" />

Upvotes: 2

Related Questions