Back to project page LearnByHeart.
The source code is released under:
Apache License
If you think the Android project LearnByHeart listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.mps.learn.pb.ui.factivities; // w w w .jav a 2 s .c o m import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.mps.learn.pb.PhraseManager; import com.mps.learn.pb.R; import com.mps.learn.pb.model.PhraseModel; import com.squareup.picasso.Picasso; public class PaintingsAdapter extends ItemsAdapter<PhraseModel> implements View.OnClickListener { public PaintingsAdapter(Context context) { super(context); setItemsList(PhraseManager.getInstance().getAllPhrases()); } @Override protected View createView(PhraseModel item, int pos, ViewGroup parent, LayoutInflater inflater) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false); ViewHolder vh = new ViewHolder(); vh.image = (ImageView) view.findViewById(R.id.list_item_image); vh.image.setOnClickListener(this); vh.title = (TextView) view.findViewById( R.id.list_item_title); view.setTag(vh); return view; } @Override protected void bindView(PhraseModel item, int pos, View convertView) { ViewHolder vh = (ViewHolder) convertView.getTag(); vh.image.setTag(item); Picasso.with(convertView.getContext()).load(item.getImageId()).into(vh.image); vh.title.setText(item.getTitle()); } @Override public void onClick(View view) { if (view.getContext() instanceof UnfoldableDetailsActivity) { UnfoldableDetailsActivity activity = (UnfoldableDetailsActivity) view.getContext(); activity.openDetails(view, (PhraseModel) view.getTag()); } } private static class ViewHolder { ImageView image; TextView title; } }