RecordListAdapter.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package de.tudarmstadt.informatik.hostage.ui2.adapter;
  2. import android.content.Context;
  3. import android.view.View;
  4. import android.widget.TextView;
  5. import java.util.ArrayList;
  6. import java.util.HashMap;
  7. import java.util.List;
  8. import de.tudarmstadt.informatik.hostage.R;
  9. import de.tudarmstadt.informatik.hostage.ui2.model.ExpandableListItem;
  10. public class RecordListAdapter extends ExpandableListAdapter {
  11. public RecordListAdapter(Context context, List<String> listSectionHeaders, HashMap<String, ArrayList<ExpandableListItem>> dataMapping) {
  12. super(context, listSectionHeaders, dataMapping);
  13. }
  14. /*****************************
  15. *
  16. * Required Methods
  17. *
  18. * ***************************/
  19. @Override
  20. public void configureCellView(View cell, int section, int row) {
  21. ExpandableListItem object = this.getDataForRow(section, row);
  22. for (String key : object.getId_Mapping().keySet()){
  23. int viewID = object.getId_Mapping().get(key);
  24. String textualInfo = object.getData().get(key);
  25. TextView tView = (TextView) cell.findViewById(viewID);
  26. tView.setText(textualInfo);
  27. }
  28. }
  29. @Override
  30. public void configureSectionHeaderView(View sectionHeader, int section) {
  31. int headerLabelID = R.id.sectionHeaderTitle;
  32. int valueLabelID = R.id.sectionHeaderValue;
  33. TextView tView = (TextView) sectionHeader.findViewById(headerLabelID);
  34. TextView vView = (TextView) sectionHeader.findViewById(valueLabelID);
  35. int value = this.getChildrenCount(section);
  36. tView.setText(this._sectionHeader.get(section));
  37. vView.setText("" + value);
  38. }
  39. @Override
  40. public int getSectionLayoutID() {
  41. return R.layout.expandable_section_header;
  42. }
  43. @Override
  44. public int getCellLayoutID() {
  45. return R.layout.record_list_item;
  46. }
  47. }