Created
August 21, 2014 03:11
-
-
Save scottagarman/562bab31126b55d84197 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
public View getView(int position, View convertView, ViewGroup parent) { | |
ListViewHolder holder = ListViewHolder.get(convertView, parent); | |
holder.name.setText("some text"); | |
return holder.root; // or convertView | |
} | |
public class ListViewHolder { | |
public static ListViewHolder get(View convertView, ViewGroup parent) { | |
if(convertView == null || convertView.getTag() == null || !(convertView.getTag() instanceof ListViewHolder)) { | |
return new ListViewHolder(parent); | |
} else { | |
return (ListViewHolder)convertView.getTag(); | |
} | |
} | |
public final View root; | |
public final TextView name; | |
private ListViewHolder(ViewGroup parent) { | |
root = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_, parent, false); | |
root.setTag(this); | |
name = (TextView)root.findViewById(R.id.item_text); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment