Created
January 3, 2013 23:27
-
-
Save indrek-koue/4448498 to your computer and use it in GitHub Desktop.
BaseAdapter broilerplate for android adapters
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
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.widget.BaseAdapter; | |
import java.util.List; | |
public abstract class MyBaseAdapter<T> extends BaseAdapter { | |
private List<T> mList; | |
private LayoutInflater mInflater; | |
private Context mContext; | |
public MyBaseAdapter(Context con, List<T> list) { | |
setInflater(LayoutInflater.from(con)); | |
setList(list); | |
setContext(con); | |
} | |
@Override | |
public int getCount() { | |
return getList().size(); | |
} | |
@Override | |
public Object getItem(int position) { | |
return getList().get(position); | |
} | |
@Override | |
public long getItemId(int position) { | |
return position; | |
} | |
public LayoutInflater getInflater() { | |
return mInflater; | |
} | |
public void setInflater(LayoutInflater inflater) { | |
this.mInflater = inflater; | |
} | |
public List<T> getList() { | |
return mList; | |
} | |
public void setList(List<T> mList) { | |
this.mList = mList; | |
} | |
public Context getContext() { | |
return mContext; | |
} | |
public void setContext(Context mContext) { | |
this.mContext = mContext; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment