-
-
Save antslava/5431129 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
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.BaseAdapter; | |
/** An implementation of {@link BaseAdapter} which uses the new/bind pattern for its views. */ | |
public abstract class BindingAdapter extends BaseAdapter { | |
@Override public final View getView(int position, View convertView, ViewGroup parent) { | |
int type = getItemViewType(position); | |
if (convertView == null) { | |
convertView = newView(type, parent); | |
} | |
bindView(position, type, convertView); | |
return convertView; | |
} | |
/** Create a new instance of a view for the specified {@code type}. */ | |
public abstract View newView(int type, ViewGroup parent); | |
/** Bind the data for the specified {@code position} to the {@code view}. */ | |
public abstract void bindView(int position, int type, View view); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment