Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | None | 0 0
  1. public class ExpandableListAdapter extends BaseExpandableListAdapter {
  2.  
  3. Activity context;
  4. ArrayList<String> s_date,c_number,d_ration,s_time,download_path,a_number,a_name;
  5. String id[];
  6. String mUrl;
  7.  
  8. private List<String> _listDataHeader; // header titles
  9. // child data in format of header title, child title
  10. private HashMap<String, List<String>> _listDataChild;
  11.  
  12. public ExpandableListAdapter(Activity context, ArrayList<String> start_date, ArrayList<String> caller_number, ArrayList<String> duration,ArrayList<String> start_time, ArrayList<String> download_path, ArrayList<String> agent_number, ArrayList<String> agent_name) {
  13. this.context=context;
  14. this.s_date=start_date;
  15. this.c_number=caller_number;
  16. this.d_ration=duration;
  17. this.s_time=start_time;
  18. this.download_path=download_path;
  19. this.a_number=agent_number;
  20. this.a_name=agent_name;
  21. }
  22.  
  23. @Override
  24. public Object getChild(int groupPosition, int childPosititon) {
  25. return this._listDataChild.get(this._listDataHeader.get(groupPosition))
  26. .get(childPosititon);
  27. }
  28.  
  29. @Override
  30. public long getChildId(int groupPosition, int childPosition) {
  31. return childPosition;
  32. }
  33.  
  34. @Override
  35. public View getChildView(final int groupPosition, final int childPosition,
  36. boolean isLastChild, View convertView, ViewGroup parent) {
  37.  
  38. final String childText = (String) getChild(groupPosition, childPosition);
  39.  
  40. if (convertView == null) {
  41. LayoutInflater infalInflater = (LayoutInflater) this.context
  42. .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  43. convertView = infalInflater.inflate(R.layout.list_item, null);
  44. }
  45.  
  46. Button play_button=(Button) convertView.findViewById(R.id.play);
  47. play_button.setOnClickListener(new View.OnClickListener() {
  48. @Override
  49. public void onClick(View view) {
  50.  
  51. Log.d("play child is",childText);
  52.  
  53. }
  54. });
  55.  
  56. Button download_button=(Button) convertView.findViewById(R.id.download);
  57. download_button.setOnClickListener(new View.OnClickListener() {
  58. @Override
  59. public void onClick(View view) {
  60.  
  61. Log.d("download child is",childText);
  62.  
  63. }
  64. });
  65.  
  66. }
  67.  
  68. @Override
  69. public int getChildrenCount(int groupPosition) {
  70. return this._listDataChild.get(this._listDataHeader.get(groupPosition))
  71. .size();
  72. }
  73.  
  74. @Override
  75. public Object getGroup(int groupPosition) {
  76. return this._listDataHeader.get(groupPosition);
  77. }
  78.  
  79. @Override
  80. public int getGroupCount() {
  81. return this.s_date.size();
  82. }
  83.  
  84. @Override
  85. public long getGroupId(int groupPosition) {
  86. return groupPosition;
  87. }
  88.  
  89. @Override
  90. public View getGroupView(int groupPosition, boolean isExpanded,
  91. View convertView, ViewGroup parent) {
  92. String headerTitle = (String) getGroup(groupPosition);
  93. if (convertView == null) {
  94. LayoutInflater infalInflater = (LayoutInflater) this.context
  95. .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  96. convertView = infalInflater.inflate(R.layout.list_group, null);
  97. }
  98.  
  99. TextView start_date = (TextView) convertView.findViewById(R.id.start_date);
  100. start_date.setText(s_date.get(groupPosition));
  101. TextView caller_number = (TextView) convertView.findViewById(R.id.caller_number);
  102. caller_number.setText(c_number.get(groupPosition));
  103. TextView duration = (TextView) convertView.findViewById(R.id.duration);
  104. duration.setText(d_ration.get(groupPosition));
  105. TextView start_time = (TextView) convertView.findViewById(R.id.start_time);
  106. start_time.setText(s_time.get(groupPosition));
  107. TextView agent_name = (TextView) convertView.findViewById(R.id.agent_name);
  108. agent_name.setText(a_name.get(groupPosition));
  109. TextView agent_number = (TextView) convertView.findViewById(R.id.agent_number);
  110. agent_number.setText(a_number.get(groupPosition));
  111. // start_date.setTypeface(null, Typeface.BOLD);
  112. // start_date.setText(headerTitle);
  113.  
  114. return convertView;
  115. }
  116.  
  117.  
  118. @Override
  119. public boolean hasStableIds() {
  120. return false;
  121. }
  122.  
  123. @Override
  124. public boolean isChildSelectable(int groupPosition, int childPosition) {
  125. return true;
  126. }
  127.  
  128. ExpandableListAdapter a=new ExpandableListAdapter(MainScreen.this,start_date,caller_number,duration,start_time,download_path,agent_number,agent_name);
  129. data_list.setAdapter(a);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement