1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
public class ExpandListStockAdapter extends BaseExpandableListAdapter {
private Context context;
private ArrayList<Stock> groups;
public ExpandListStockAdapter(Context context, ArrayList<Stock> groups) {
this.context = context;
this.groups = groups;
}
public void addItem(Rf item, Stock group) {
if (!groups.contains(group)) {
groups.add(group);
}
int index = groups.indexOf(group);
ArrayList<Rf> ch = groups.get(index).getTabRfs();
ch.add(item);
groups.get(index).setTabsRfs(ch);
}
public Object getChild(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
ArrayList<Rf> chList = groups.get(groupPosition).getTabRfs();
return chList.get(childPosition);
}
public long getChildId(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return childPosition;
}
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View view,
ViewGroup parent) {
Rf child = (Rf) getChild(groupPosition, childPosition);
if (view == null) {
LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
view = infalInflater.inflate(R.layout.item_pf, null);
}
TextView tvType = (TextView) view.findViewById(R.id.tvType);
TextView tvQtProd = (TextView) view.findViewById(R.id.tvQtProd);
TextView tvQtLiv = (TextView) view.findViewById(R.id.tvQtLiv);
TextView tvQtStock = (TextView) view.findViewById(R.id.tvStock);
if(childPosition==0)
{
tvType.setText("Type");
tvType.setTypeface(Typeface.SERIF,Typeface.BOLD);
tvQtProd.setText("Qte Prod");
tvQtProd.setTypeface(Typeface.SERIF,Typeface.BOLD);
tvQtLiv.setText("Qte Liv");
tvQtLiv.setTypeface(Typeface.SERIF,Typeface.BOLD);
tvQtStock.setText("Qte Disp");
tvQtStock.setTypeface(Typeface.SERIF,Typeface.BOLD);
}
else
{
tvType.setText(child.getType().toString());
tvQtProd.setText(""+child.getQt_prod());
tvQtLiv.setText(""+child.getQt_liv());
tvQtStock.setText(""+child.getQt_stock());
}
//tv.setTag(child.getTag());
// TODO Auto-generated method stub
return view;
}
public int getChildrenCount(int groupPosition) {
// TODO Auto-generated method stub
ArrayList<Rf> chList = groups.get(groupPosition).getTabRfs();
return chList.size();
}
public Object getGroup(int groupPosition) {
// TODO Auto-generated method stub
return groups.get(groupPosition);
}
public int getGroupCount() {
// TODO Auto-generated method stub
return groups.size();
}
public long getGroupId(int groupPosition) {
// TODO Auto-generated method stub
return groupPosition;
}
public View getGroupView(int groupPosition, boolean isLastChild, View view,
ViewGroup parent) {
Stock group = (Stock) getGroup(groupPosition);
if (view == null) {
LayoutInflater inf = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
view = inf.inflate(R.layout.item_stock, null);
}
TextView tv = (TextView) view.findViewById(R.id.tvGroup);
tv.setText(group.getEspece());
// TODO Auto-generated method stub
return view;
}
public boolean hasStableIds() {
// TODO Auto-generated method stub
return true;
}
public boolean isChildSelectable(int arg0, int arg1) {
// TODO Auto-generated method stub
return true;
}
} |
Partager