Created
January 8, 2019 21:23
-
-
Save caneryilmaz/e8daadf03aef644ff7efc458e86840c8 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 class MyClassAdapter extends ArrayAdapter<MyClass> { | |
private static class ViewHolder { | |
private TextView itemView; | |
} | |
public MyClassAdapter(Context context, int textViewResourceId, ArrayList<MyClass> items) { | |
super(context, textViewResourceId, items); | |
} | |
public View getView(int position, View convertView, ViewGroup parent) { | |
if (convertView == null) { | |
convertView = LayoutInflater.from(this.getContext()) | |
.inflate(R.layout.listview_association, parent, false); | |
viewHolder = new ViewHolder(); | |
viewHolder.itemView = (TextView) convertView.findViewById(R.id.ItemView); | |
convertView.setTag(viewHolder); | |
} else { | |
viewHolder = (ViewHolder) convertView.getTag(); | |
} | |
MyClass item = getItem(position); | |
if (item!= null) { | |
// My layout has only one TextView | |
// do whatever you want with your string and long | |
viewHolder.itemView.setText(String.format("%s %d", item.reason, item.long_val)); | |
} | |
return convertView; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment