How do you add in ExpandableListView to ParentGroup ImageButton?
-
In order to be addressed, it is necessary to reconcile the records downloaded from the server
SQLite
The base of the device itself and add/authorize in the absence/acquisition (addition to selected). Already done a method of fillingExpandableListView
but I don't know how to addImageButton
♪ Code of methodpublic void setExpandableListView(ArrayList<Dish> val){ Map<String, String> map; ArrayList<Map<String, String>> groupDataList = new ArrayList<>(); ArrayList<Dish> values = val;
for (int i = 0; i < values.size(); i++) { map = new HashMap<>(); map.put("dishName", values.get(i).getName()); groupDataList.add(map); } String groupFrom[] = new String[] { "dishName" }; int groupTo[] = new int[] { android.R.id.text1 }; ArrayList<ArrayList<Map<String, String>>> сhildDataList = new ArrayList<>(); for (int i = 0; i < values.size(); i++) { ArrayList<Map<String, String>> сhildDataItemList = new ArrayList<>(); map = new HashMap<>(); map.put("dishRecipe", values.get(i).getRecipe()); сhildDataItemList.add(map); сhildDataList.add(сhildDataItemList); } String childFrom[] = new String[] { "dishRecipe" }; int childTo[] = new int[] { android.R.id.text1 }; final SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter( this, groupDataList, android.R.layout.simple_expandable_list_item_1, groupFrom, groupTo, сhildDataList, android.R.layout.simple_list_item_1, childFrom, childTo); final ExpandableListView list = (ExpandableListView) findViewById(R.id.list_recipes); list.setAdapter(adapter); list.deferNotifyDataSetChanged(); list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View itemClicked, int position, long id) { } }); list.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (firstVisibleItem + visibleItemCount == currentNumOfDishes){ String[] query = new String[2]; query[1] = "get_dishes"; query[0] = "SELECT * FROM Dishes WHERE _id > " + currentNumOfDishes + " AND _id <= " + neededNumOfDishes; new AsyncRequest(Recipes_List.this).execute(query); scroll = currentNumOfDishes; scrollcount = visibleItemCount; currentNumOfDishes = neededNumOfDishes; neededNumOfDishes += 20; } } }); if (scroll > 1){ list.setSelectedGroup(scroll-scrollcount); }
}
-
As layout for the groups, you now use the resources provided by the Android: android.R.id.text1. You need to create your resource layout for groups with the necessary markings (appendix ImageButton, etc.), and the code already refers to it accordingly. Well, it's likely that the same should be done for the elements of a child.