@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.XXX);
mListView.setAdapter(new MyAdapter(this));
}
public class MyAdapter extends BaseAdapter{
private LayoutInflater mLayoutInflater;
public MyAdapter(Context context) {
this.mLayoutInflater = LayoutInflater.from(context);
}
@Override
public int getCount(){
return XXX;
}
@Override
public Object getItem(int arg0){
return null;
}
@Override
public long getItemId(int arg0){
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
ViewHolder mViewHolder = null;
if (convertView == null) {
mViewHolder = new ViewHolder();
convertView = mLayoutInflater.inflate(R.layout.XXX, null);
mViewHolder.mTitle= (TextView) convertView.findViewById(R.id.XXX);
mViewHolder.mAuthor= (TextView) convertView.findViewById(R.id.XXX);
convertView.setTag(mViewHolder);
}else {
mViewHolder = (ViewHolder) convertView.getTag();
}
mViewHolder.mTitle.setText("XXX");
mViewHolder.mAuthor.setText("XXX");
return convertView;
}
public final class ViewHolder{
public TextView mTitle;
public TextView mAuthor;
}