Android Open Source - carousel-android My Adapter






From Project

Back to project page carousel-android.

License

The source code is released under:

The Code Project Open License (CPOL) 1.02 Preamble This License governs Your use of the Work. This License is intended to allow developers to use the Source Code and Executable Files provided as par...

If you think the Android project carousel-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package fr.rolandl.sample.carousel.adapter;
/* www . j  av a  2  s .  c  o m*/
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import fr.rolandl.carousel.CarouselAdapter;
import fr.rolandl.carousel.CarouselItem;
import fr.rolandl.sample.carousel.R;
import fr.rolandl.sample.carousel.bo.Photo;
import java.util.List;

/**
 * @author Ludovic ROLAND
 * @since 2014.12.20
 */
public final class MyAdapter
    extends CarouselAdapter<Photo>
{

  public static final class PhotoItem
      extends CarouselItem<Photo>
  {

    private ImageView image;

    private TextView name;

    private Context context;

    public PhotoItem(Context context)
    {
      super(context, R.layout.item);
      this.context = context;
    }

    @Override
    public void extractView(View view)
    {
      image = (ImageView) view.findViewById(R.id.image);
      name = (TextView) view.findViewById(R.id.name);
    }

    @Override
    public void update(Photo photo)
    {
      image.setImageResource(getResources().getIdentifier(photo.image, "drawable", context.getPackageName()));
      name.setText(photo.name);
    }

  }

  public MyAdapter(Context context, List<Photo> photos)
  {
    super(context, photos);
  }

  @Override
  public CarouselItem<Photo> getCarouselItem(Context context)
  {
    return new PhotoItem(context);
  }

}




Java Source Code List

fr.rolandl.carousel.CarouselAdapter.java
fr.rolandl.carousel.CarouselBaseAdapter.java
fr.rolandl.carousel.CarouselItem.java
fr.rolandl.carousel.CarouselSpinner.java
fr.rolandl.carousel.Carousel.java
fr.rolandl.carousel.Rotator.java
fr.rolandl.sample.carousel.MainActivity.java
fr.rolandl.sample.carousel.adapter.MyAdapter.java
fr.rolandl.sample.carousel.bo.Photo.java