class GroupMemberAdapter extends BaseAdapter{
private Context context ;
private int resource ;
public GroupMemberAdapter(Context context, int resource) {
this.context = context;
this.resource = resource;
}
//在后面需要加上两个按钮,需要将grid的总数加上2
@Override
public int getCount() {
return (memberList .size()+2);
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null ;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
if(convertView == null){
// 获得ViewHolder对象
viewHolder = new ViewHolder();
// 导入布局并赋值给 convertview
convertView = LayoutInflater.from(context).inflate( resource, null);
viewHolder. headerView = (HeaderView)convertView.findViewById(R.id.item_groupmember_photo);
viewHolder. nameTextView = (TextView)convertView.findViewById(R.id.item_groupmember_name);
viewHolder. photoTextView = (TextView)convertView.findViewById(R.id.item_groupmember_phototext);
convertView.setTag(viewHolder);
} else{
viewHolder =(ViewHolder)convertView.getTag();
}
LXLog. e("总行数", String. valueOf(memberList.size()));
LXLog. e("行", String. valueOf(position));
final HeaderView imageView = viewHolder.headerView ;
final TextView textView = viewHolder.photoTextView ;
//加上加号按钮
if(position == memberList.size()){
imageView.setImageBitmap(BitmapFactory. decodeResource(
getResources(), R.drawable. btn_add));
imageView.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(GroupMemberActivity.this ,AddUserToGroupActivity.class);
intent.putExtra( "actionType", 2);//添加成员
intent.putExtra( "groupId", groupId );
startActivityForResult(intent, REQUEST_CODE_EDIT_MEMBER );
}
});
//加上减号按钮
} else if (position == memberList.size()+1){
imageView.setImageBitmap(BitmapFactory. decodeResource(
getResources(), R.drawable. add_del));
imageView.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(GroupMemberActivity.this ,AddUserToGroupActivity.class);
intent.putExtra( "actionType", 3);//添加成员
intent.putExtra( "groupId", groupId );
startActivityForResult(intent, REQUEST_CODE_EDIT_MEMBER );
}
});
} else{
if(memberList .size()>0){
Staff staff = memberList.get(position);
if(staff != null){
viewHolder. nameTextView.setText(staff.getName());
String serviceAddress = jyBoxApplication.getServiceAddress();
String path ="http://"+serviceAddress+staff.getPath();
if(Utils.isInputCorrect(staff.getPath())){
Utils. setDefaultPhoto(getApplicationContext(), textView, imageView,staff.getName(), staff.getId());
} else{
loader.displayImage(path, imageView,options);
}
}
}
}
return convertView;
}
}
--------------
spring mvc+tomcat源码分析视频 (复制链接在浏览器打开)
https://study.163.com/course/courseMain.htm?share=2&shareId=480000001919582&courseId=1209399899&_trace_c_p_k2_=6d81bc445e9c462ab8d6345e40f6b0bf