public classTestListAdapter extends BaseAdapter {privateContext mContext;private ListstrList;public TestListAdapter(Context context, Listlist) {
super();this.mContext =context;this.strList =list;
}
@Overridepublic intgetCount() {//TODO Auto-generated method stub
returnstrList.size();
}
@Overridepublic Object getItem(intposition) {//TODO Auto-generated method stub
returnposition;
}
@Overridepublic long getItemId(intposition) {//TODO Auto-generated method stub
returnposition;
}
@Overridepublic View getView(intposition, View convertView, ViewGroup parent) {//TODO Auto-generated method stub
ViewHolder holder = null;if (null ==convertView) {
convertView= LayoutInflater.from(mContext).inflate(R.layout.line, null);
holder= newViewHolder();
holder.iDText=(TextView) convertView.findViewById(R.id.textView_id);
holder.strText=(TextView) convertView.findViewById(R.id.textView_str);
convertView.setTag(holder);
}else{
holder=(ViewHolder) convertView.getTag();
}
holder.iDText.setText(position+ "");
String str= strList.get(position);
holder.strText.setText(str);returnconvertView;
}private static classViewHolder {privateTextView iDText;privateTextView strText;
}public void updataView(intposi, ListView listView) {int visibleFirstPosi =listView.getFirstVisiblePosition();int visibleLastPosi =listView.getLastVisiblePosition();if (posi >= visibleFirstPosi && posi <=visibleLastPosi) {
View view= listView.getChildAt(posi -visibleFirstPosi);
ViewHolder holder=(ViewHolder) view.getTag();
String txt=holder.strText.getText().toString();
txt= txt + "++;";
holder.strText.setText(txt);
strList.set(posi, txt);
}else{
String txt= strList.get(posi);
txt= txt + "++;";
strList.set(posi, txt);
}
}
}