Skip to content

Instantly share code, notes, and snippets.

@peitek
Created February 6, 2017 19:38
Show Gist options
  • Save peitek/134293199e43b603775384aa693ba2e8 to your computer and use it in GitHub Desktop.
Save peitek/134293199e43b603775384aa693ba2e8 to your computer and use it in GitHub Desktop.
package io.futurestud.retrofit1.ui.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.List;
import io.futurestud.retrofit1.R;
import io.futurestud.retrofit1.api.model.GitHubRepo;
/**
* Created by norman on 12/26/16.
*/
public class GitHubRepoAdapter extends ArrayAdapter<GitHubRepo> {
private Context context;
private List<GitHubRepo> values;
public GitHubRepoAdapter(Context context, List<GitHubRepo> values) {
super(context, R.layout.list_item_pagination, values);
this.context = context;
this.values = values;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
if (row == null) {
LayoutInflater inflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.list_item_pagination, parent, false);
}
TextView textView = (TextView) row.findViewById(R.id.list_item_pagination_text);
GitHubRepo item = values.get(position);
String message = item.getName();
textView.setText(message);
return row;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment