public void initData(ArrayList<String> list01,ArrayList<String> list02){
for (int i = 0; i < list01.size(); i++) {
entity = new DocumentDB();
entity.setname(list01.get(i));
entity.setliuchengType(list02.get(i));
mDataArray.add(entity);
}
adapter = new DocumentViewAdapter(this,mDataArray);
listview_document.setAdapter(adapter);
}
package com.domor.oa.function;
import java.util.List;
import com.domor.oa.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class DocumentViewAdapter extends BaseAdapter {
public static interface IMsgViewType {
int IMVT_COM_MSG = 0;
int IMVT_TO_MSG = 1;
}
private static final String TAG = DocumentViewAdapter.class
.getSimpleName();
private List<DocumentDB> coll;
private Context ctx;
private LayoutInflater mInflater;
public DocumentViewAdapter(Context context, List<DocumentDB> coll) {
ctx = context;
this.coll = coll;
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return coll.size();
}
public Object getItem(int position) {
return coll.get(position);
}
public long getItemId(int position) {
return position;
}
public int getItemViewType(int position) {
// TODO Auto-generated method stub
DocumentDB entity = coll.get(position);
if (entity.getMsgType()) {
return IMsgViewType.IMVT_COM_MSG;
} else {
return IMsgViewType.IMVT_TO_MSG;
}
}
public int getViewTypeCount() {
// TODO Auto-generated method stub
return 2;
}
public View getView(int position, View convertView, ViewGroup parent) {
DocumentDB entity = coll.get(position);
boolean isComMsg = entity.getMsgType();
ViewHolder viewHolder = null;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.activity_documentlist, null);
viewHolder = new ViewHolder();
viewHolder.document_name = (TextView) convertView
.findViewById(R.id.document_name);
viewHolder.document_type = (TextView) convertView
.findViewById(R.id.document_type);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
String a = entity.getdaibanTime();
viewHolder.document_name.setText(entity.getname());
viewHolder.document_type.setText(entity.getliuchengType());
return convertView;
}
static class ViewHolder {
public TextView document_name;
public TextView medition_list_name;
public TextView document_type;
public boolean isComMsg = true;
}
}
package com.domor.oa.function;
public class DocumentDB {
private String daibanTime;
private String name;
private String liuchengType;
private boolean isComMeg = true;
public boolean getMsgType() {
return isComMeg;
}
public DocumentDB() {
}
public DocumentDB(String daibanTime, String name,
String liuchengType, boolean isComMsg) {
super();
this.daibanTime = daibanTime;
this.name = name;
this.liuchengType = liuchengType;
this.isComMeg = isComMsg;
}
public String getdaibanTime() {
return daibanTime;
}
public void setdaibanTime(String daibanTime) {
this.daibanTime = daibanTime;
}
public String getname() {
return name;
}
public void setname(String name) {
this.name = name;
}
public String getliuchengType() {
return liuchengType;
}
public void setliuchengType(String liuchengType) {
this.liuchengType = liuchengType;
}
public boolean isComMeg() {
return isComMeg;
}
public void setComMeg(boolean isComMeg) {
this.isComMeg = isComMeg;
}
}