Created
July 20, 2016 16:15
-
-
Save roshanpal/65712829504e925a1c01cf66f0ed5cea to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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