Added data to ListView, but the text color is hardly distinguishable from white. As far as I know, the default text color in the ListView is black. I tried to add the text color property in simple_list_item_1, which uses ListView, but the text color has not changed. What could be the reason?
- Can xml show your simple_list_item_1 and ListView? - V.March
- And the code with c "onCreate" is better - V.March
1 answer
Try creating your own list item layout. To do this, right-click the res / layout folder and select New → Layout resounce file . In the dialog box that opens, specify the name of the file (for example, custom_listview_item ), and in the Root element, remove the LinearLayout and enter TextView . Next, open the created file and edit it: add the necessary attributes for the TextView ( id , layout_width , layout_height , textSize and others), as well as the textColor attribute, in the value of which you specify the desired color (eg black #000000 ).
Most likely, you did not create your own adapter class inherited from the BaseAdapter , but used the following call:
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, data); listView.setAdapter(adapter); Change the resource to your own
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.custon_list_item, data); 