Guest User

Untitled

a guest
Apr 25th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. public class SessionsFragment extends Fragment {
  2.  
  3. ExpandableListAdapter expandableListAdapter;
  4. ExpandableListView expandableListView;
  5. List<String> listDataHeader;
  6. HashMap<String, List<String>> listDataChild;
  7. ImageButton addButton;
  8.  
  9. @Override
  10. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  11. View view = inflater.inflate(R.layout.fragment_sessions, container, false);
  12.  
  13. // Get the ListView
  14. expandableListView = view.findViewById(R.id.sessionsExpandableListView);
  15.  
  16. // Prepare the list data
  17. prepareListData();
  18.  
  19. expandableListAdapter = new ExpandableListAdapter(getContext(), listDataHeader, listDataChild);
  20.  
  21. // Set the list adapter and expand lists by default
  22. expandableListView.setAdapter(expandableListAdapter);
  23. expandableListView.expandGroup(0);
  24.  
  25. // Get button values
  26. addButton = view.findViewById(R.id.addButton);
  27. addButton.setOnClickListener(new ImageButton.OnClickListener() {
  28. @Override
  29. public void onClick(View view) {
  30. Toast.makeText(getActivity(), "Session added", Toast.LENGTH_SHORT).show();
  31. }
  32. });
  33.  
  34. return view;
  35. }
  36.  
  37. <RelativeLayout
  38. xmlns:android="http://schemas.android.com/apk/res/android"
  39. android:orientation="vertical"
  40. android:layout_width="match_parent"
  41. android:layout_height="55dp">
  42.  
  43. <TextView
  44. android:id="@+id/listItem"
  45. android:layout_width="match_parent"
  46. android:layout_height="wrap_content"
  47. android:textSize="16sp"
  48. android:paddingTop="5dp"
  49. android:paddingBottom="5dp" />
  50. <!--android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"/>-->
  51.  
  52. <ImageButton
  53. android:id="@+id/addButton"
  54. android:layout_width="wrap_content"
  55. android:layout_height="match_parent"
  56. android:src="@drawable/ic_add_black_24dp"
  57. android:layout_alignParentRight="true" />
Add Comment
Please, Sign In to add comment