Skip to content

Instantly share code, notes, and snippets.

@roshanpal
Created July 20, 2016 16:15
Show Gist options
  • Save roshanpal/65712829504e925a1c01cf66f0ed5cea to your computer and use it in GitHub Desktop.
Save roshanpal/65712829504e925a1c01cf66f0ed5cea to your computer and use it in GitHub Desktop.
private class MyListAdapter extends ArrayAdapter<Newspaper> {
public MyListAdapter() {
super(MainActivity.this, R.layout.item_view, newsPapers);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View itemView = convertView;
if(convertView == null) {
itemView = getLayoutInflater().inflate(R.layout.item_view, parent, false);
}
Newspaper currentPaper = newsPapers.get(position);
ImageView imageView = (ImageView)itemView.findViewById(R.id.item_icon);
imageView.setImageResource(currentPaper.getIconId());
TextView itemText = (TextView)itemView.findViewById(R.id.item_text);
itemText.setText(currentPaper.getName());
return itemView;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment