RecordListAdapter.java 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. /**
  12. * Constructor
  13. * @param context the context
  14. * @param listSectionHeaders the section titles
  15. * @param dataMapping HashMap<String, ArrayList<{@link ExpandableListItem ExpandableListItem}>> the data to visualise
  16. */
  17. public RecordListAdapter(Context context, List<String> listSectionHeaders, HashMap<String, ArrayList<ExpandableListItem>> dataMapping) {
  18. super(context, listSectionHeaders, dataMapping);
  19. }
  20. /*****************************
  21. *
  22. * Required Methods
  23. *
  24. * ***************************/
  25. @Override
  26. public void configureCellView(View cell, int section, int row) {
  27. ExpandableListItem object = this.getDataForRow(section, row);
  28. for (String key : object.getId_Mapping().keySet()){
  29. int viewID = object.getId_Mapping().get(key);
  30. String textualInfo = object.getData().get(key);
  31. TextView tView = (TextView) cell.findViewById(viewID);
  32. tView.setText(textualInfo);
  33. }
  34. }
  35. @Override
  36. public void configureSectionHeaderView(View sectionHeader, int section) {
  37. int headerLabelID = R.id.sectionHeaderTitle;
  38. int valueLabelID = R.id.sectionHeaderValue;
  39. TextView tView = (TextView) sectionHeader.findViewById(headerLabelID);
  40. TextView vView = (TextView) sectionHeader.findViewById(valueLabelID);
  41. int value = this.getChildrenCount(section);
  42. tView.setText(this._sectionHeader.get(section));
  43. vView.setText("" + value);
  44. }
  45. @Override
  46. public int getSectionLayoutID() {
  47. return R.layout.expandable_section_header;
  48. }
  49. @Override
  50. public int getCellLayoutID() {
  51. return R.layout.record_list_item;
  52. }
  53. }