Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

DataMapping

Florent CHAMPIGNY edited this page Aug 3, 2015 · 1 revision

#DataMapping

##Usage from layout

android:tag="setText($user)" //will call toString
android:tag="setText($user.getName())" //will call getName() on the user
android:tag="setText($user.name)" //will call getName() on the user
android:tag="setText($user.getCity())" //will call getCity, then city.toString()
android:tag="setText($user.getCity().getLocation())" //will call getCity, then city.getLocation()
android:tag="setText($user.city.location)" //will call getCity, then city.getLocation()

##Map your object

User myUser = ...//your initialisation

Carpaccio carpaccio = (Carpaccio)findViewById(R.id.carpaccio);
carpaccio.mapObject("user",myUser);

#TextView

Please see at wiki/TextView

<com.github.florent37.carpaccio.Carpaccio
        app:register="
            com.github.florent37.carpaccio.controllers.TextViewController;
        ">

        <TextView
             android:tag="
                 setText($user.getName())
             " />
</com.github.florent37.carpaccio.Carpaccio>

#ImageView

Please see at wiki/ImageView

<com.github.florent37.carpaccio.Carpaccio
        app:register="
            com.github.florent37.carpaccio.controllers.ImageViewController;
        ">

        <ImageView
             android:tag="
                 url($user.image)
             " />
</com.github.florent37.carpaccio.Carpaccio>

#RecyclerView

Please see at wiki/RecyclerView

<com.github.florent37.carpaccio.Carpaccio app:register=" com.github.florent37.carpaccio.controllers.CommonViewController; ">

    <android.support.v7.widget.RecyclerView
         android:tag="
             adapter(user,R.layout.cell_user)
         " />

</com.github.florent37.carpaccio.Carpaccio>

Clone this wiki locally