-
-
Save laggedHero/750e42cc217044b4f223 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
// Without a View Holder | |
@Override | |
publicView getView(int itempos, View convertView, ViewGroup parent) { | |
// Check if the convertview is null, if it is null it probably means that this | |
// is the first time the view has been displayed | |
if (convertView == null) { | |
convertView = View.inflate(context, R.layout.list_content_layout, null); | |
} | |
// If it is not null, you can just reuse it from the recycler | |
TextView txtcontent = (TextView) convertView.findViewById(R.id.textView1); | |
ImageView imgcontent = (ImageView) convertView.findViewById(R.id.imageView1); | |
Paintings paintingcontent = content[itempos]; | |
txtcontent.setText(paintingcontent.imagetitle); | |
imgcontent.setImageResource(paintingcontent.drawableresid); | |
// return the view for a single item in the listview | |
return convertView; | |
} | |
// With a View Holder | |
@Override | |
publicView getView(int itempos, View convertView, ViewGroup parent) { | |
ViewHolder holder; | |
// Check if the convertview is null, if it is null it probably means that this | |
// is the first time the view has been displayed | |
if (convertView == null) { | |
convertView = View.inflate(context, R.layout.list_content_layout, null); | |
holder = new ViewHolder(); | |
holder.text = (TextView) convertView.findViewById(R.id.textView1); | |
holder.image = (ImageView) convertView.findViewById(R.id.imageView1); | |
convertView.setTag(holder); | |
} else { | |
holder = (ViewHolder) convertView.getTag(); | |
} | |
Paintings paintingcontent = content[itempos]; | |
holder.text.setText(paintingcontent.imagetitle); | |
holder.image.setImageResource(paintingcontent.drawableresid); | |
// return the view for a single item in the listview | |
return convertView; | |
} | |
// The View Holder | |
static class ViewHolder { | |
TextView text; | |
ImageView image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment