When adding an ExpandedListView type list to the fragment, the text color of the elements of this list is set to white and, of course, on a white background, the list is almost invisible:
I tried to add the same list to the activit, everything was displayed as it should:
The only way out (for now) is to change the color of the background of the list (or the list in which the list is located). But still I would like to achieve a display like in the second screenshot. Thank you in advance!
The layout code in which the list is:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <ExpandableListView android:id="@+id/elvMain" android:layout_width="match_parent" android:layout_height="wrap_content"> </ExpandableListView> </LinearLayout> </LinearLayout> Fragment code:
public class ExercisesFragment extends Fragment{ ExpandableListView elvMain; ExercisesAdapter EA; SimpleExpandableListAdapter adapter; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.exercises_fragment, container, false); EA = new ExercisesAdapter(getActivity()); adapter = EA.getAdapter(); elvMain = (ExpandableListView) rootView.findViewById(R.id.elvMain); //elvMain.setBackgroundColor(getResources().getColor(R.color.black)); elvMain.setAdapter(adapter); return rootView; } } ExercisesAdapter code:
public class ExercisesAdapter { final String ATTR_GROUP_NAME= "groupName"; final String ATTR_EXERC_NAME= "exerName"; // Π½Π°Π·Π²Π°Π½ΠΈΡ Π³ΡΡΠΏΠΏ ΡΠΏΡΠ°ΠΆΠ½Π΅Π½ΠΈΠΉ String[] groups = new String[] {"Group 1", "Group 2", "Group 3", "Group 4","Group 5", "Group 6", "Group 7", "Group 8", "Group 9"}; // Π½Π°Π·Π²Π°Π½ΠΈΡ ΡΠΏΡΠ°ΠΆΠ½Π΅Π½ΠΈΠΉ String[] Group1 = new String[] {"Exercise 1", "Exercise 2", "Exercise 3", "Exercise 4", "Exercise 5"}; String[] Group2 = new String[] {"Exercise 1", "Exercise 2", "Exercise 3", "Exercise 4", "Exercise 5"}; String[] Group3 = new String[] {"Exercise 1", "Exercise 2", "Exercise 3", "Exercise 4", "Exercise 5"}; String[] Group4 = new String[] {"Exercise 1", "Exercise 2", "Exercise 3", "Exercise 4", "Exercise 5"}; String[] Group5 = new String[] {"Exercise 1", "Exercise 2", "Exercise 3", "Exercise 4", "Exercise 5"}; String[] Group6 = new String[] {"Exercise 1", "Exercise 2", "Exercise 3", "Exercise 4", "Exercise 5"}; String[] Group7 = new String[] {"Exercise 1", "Exercise 2", "Exercise 3", "Exercise 4", "Exercise 5"}; String[] Group8 = new String[] {"Exercise 1", "Exercise 2", "Exercise 3", "Exercise 4", "Exercise 5"}; String[] Group9 = new String[] {"Exercise 1", "Exercise 2", "Exercise 3", "Exercise 4", "Exercise 5"}; // ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΡ Π΄Π»Ρ Π³ΡΡΠΏΠΏ ArrayList<Map<String, String>> groupData; // ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΡ Π΄Π»Ρ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² ΠΎΠ΄Π½ΠΎΠΉ Π³ΡΡΠΏΠΏΡ ArrayList<Map<String, String>> childDataItem; // ΠΎΠ±ΡΠ°Ρ ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΡ Π΄Π»Ρ ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΠΉ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² ArrayList<ArrayList<Map<String, String>>> childData; // Π² ΠΈΡΠΎΠ³Π΅ ΠΏΠΎΠ»ΡΡΠΈΡΡΡ childData = ArrayList<childDataItem> // ΡΠΏΠΈΡΠΎΠΊ Π°ΡΡΡΠΈΠ±ΡΡΠΎΠ² Π³ΡΡΠΏΠΏΡ ΠΈΠ»ΠΈ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° Map<String, String> m; Context ctx; ExercisesAdapter(Context _ctx) {ctx = _ctx;} SimpleExpandableListAdapter adapter; SimpleExpandableListAdapter getAdapter() { // Π·Π°ΠΏΠΎΠ»Π½ΡΠ΅ΠΌ ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΡ Π³ΡΡΠΏΠΏ ΠΈΠ· ΠΌΠ°ΡΡΠΈΠ²Π° Ρ Π½Π°Π·Π²Π°Π½ΠΈΡΠΌΠΈ Π³ΡΡΠΏΠΏ groupData = new ArrayList<Map<String, String>>(); for (String group : groups) { // Π·Π°ΠΏΠΎΠ»Π½ΡΠ΅ΠΌ ΡΠΏΠΈΡΠΎΠΊ Π°ΡΡΡΠΈΠ±ΡΡΠΎΠ² Π΄Π»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠΉ Π³ΡΡΠΏΠΏΡ m = new HashMap<String, String>(); m.put(ATTR_GROUP_NAME, group); // ΠΈΠΌΡ Π³ΡΡΠΏΠΏΡ groupData.add(m); } // ΡΠΏΠΈΡΠΎΠΊ Π°ΡΡΠΈΠ±ΡΡΠΎΠ² Π³ΡΡΠΏΠΏ Π΄Π»Ρ ΡΡΠ΅Π½ΠΈΡ String groupFrom[] = new String[] {ATTR_GROUP_NAME}; // ΡΠΏΠΈΡΠΎΠΊ ID view-ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ², Π² ΠΊΠΎΡΠΎΡΡΠ΅ Π±ΡΠ΄Π΅Ρ ΠΏΠΎΠΌΠ΅ΡΠ΅Π½Ρ Π°ΡΡΡΠΈΠ±ΡΡΡ Π³ΡΡΠΏΠΏ int groupTo[] = new int[] {android.R.id.text1}; // ΡΠΎΠ·Π΄Π°Π΅ΠΌ ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΡ Π΄Π»Ρ ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΠΉ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² childData = new ArrayList<ArrayList<Map<String, String>>>(); add(childData, Group1); add(childData, Group2); add(childData, Group3); add(childData, Group4); add(childData, Group5); add(childData, Group6); add(childData, Group7); add(childData, Group8); add(childData, Group9); // ΡΠΏΠΈΡΠΎΠΊ Π°ΡΡΡΠΈΠ±ΡΡΠΎΠ² ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² Π΄Π»Ρ ΡΡΠ΅Π½ΠΈΡ String childFrom[] = new String[] {ATTR_EXERC_NAME}; // ΡΠΏΠΈΡΠΎΠΊ ID view-ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ², Π² ΠΊΠΎΡΠΎΡΡΠ΅ Π±ΡΠ΄Π΅Ρ ΠΏΠΎΠΌΠ΅ΡΠ΅Π½Ρ Π°ΡΡΡΠΈΠ±ΡΡΡ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² int childTo[] = new int[] {android.R.id.text1}; adapter = new SimpleExpandableListAdapter( ctx, groupData, android.R.layout.simple_expandable_list_item_1, groupFrom, groupTo, childData, android.R.layout.simple_list_item_1, childFrom, childTo); return adapter; } public ArrayList<ArrayList<Map<String, String>>> add(ArrayList<ArrayList<Map<String, String>>> childData, String[] Group ){ // ΡΠΎΠ·Π΄Π°Π΅ΠΌ ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΡ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² Π΄Π»Ρ ΠΏΠ΅ΡΠ²ΠΎΠΉ Π³ΡΡΠΏΠΏΡ childDataItem = new ArrayList<Map<String, String>>(); // Π·Π°ΠΏΠΎΠ»Π½ΡΠ΅ΠΌ ΡΠΏΠΈΡΠΎΠΊ Π°ΡΡΡΠΈΠ±ΡΡΠΎΠ² Π΄Π»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° for (String exercise : Group) { m = new HashMap<String, String>(); m.put(ATTR_EXERC_NAME, exercise); // Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΡΠΏΡΠ°ΠΆΠ½Π΅Π½ΠΈΡ childDataItem.add(m); } // Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ Π² ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΡ ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΠΉ childData.add(childDataItem); return childData; } } 
