Created
February 6, 2017 19:38
-
-
Save peitek/134293199e43b603775384aa693ba2e8 to your computer and use it in GitHub Desktop.
Adapter class for https://www.youtube.com/watch?v=R4XU8yPzSx0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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