Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SessionsFragment extends Fragment {
- ExpandableListAdapter expandableListAdapter;
- ExpandableListView expandableListView;
- List<String> listDataHeader;
- HashMap<String, List<String>> listDataChild;
- ImageButton addButton;
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_sessions, container, false);
- // Get the ListView
- expandableListView = view.findViewById(R.id.sessionsExpandableListView);
- // Prepare the list data
- prepareListData();
- expandableListAdapter = new ExpandableListAdapter(getContext(), listDataHeader, listDataChild);
- // Set the list adapter and expand lists by default
- expandableListView.setAdapter(expandableListAdapter);
- expandableListView.expandGroup(0);
- // Get button values
- addButton = view.findViewById(R.id.addButton);
- addButton.setOnClickListener(new ImageButton.OnClickListener() {
- @Override
- public void onClick(View view) {
- Toast.makeText(getActivity(), "Session added", Toast.LENGTH_SHORT).show();
- }
- });
- return view;
- }
- <RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="55dp">
- <TextView
- android:id="@+id/listItem"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="16sp"
- android:paddingTop="5dp"
- android:paddingBottom="5dp" />
- <!--android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"/>-->
- <ImageButton
- android:id="@+id/addButton"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:src="@drawable/ic_add_black_24dp"
- android:layout_alignParentRight="true" />
Add Comment
Please, Sign In to add comment