Created
April 8, 2016 00:30
-
-
Save frankibem/72164bedd5a11003553b4daee215af00 to your computer and use it in GitHub Desktop.
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 com.test.leaderboard; | |
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; | |
/** | |
* @author Frank Ibem. | |
*/ | |
public class LeaderboardAdapter extends ArrayAdapter<ScoreEntry> { | |
LayoutInflater inflater; | |
public LeaderboardAdapter(Context context, List<ScoreEntry> objects) { | |
super(context, -1, objects); | |
inflater = LayoutInflater.from(context); | |
} | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
View view = inflater.inflate(R.layout.leaderboard_item, parent, false); | |
ScoreEntry entry = getItem(position); | |
TextView rank = (TextView) view.findViewById(R.id.text_rank); | |
TextView username = (TextView) view.findViewById(R.id.text_username); | |
TextView score = (TextView) view.findViewById(R.id.text_score); | |
rank.setText(Integer.toString(position + 1)); | |
username.setText(entry.getUserName()); | |
score.setText(Integer.toString(entry.getScore())); | |
return view; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment