Q:

TextView not appearing in ListView with Custom Adapter

I have a ListView that I'm trying to populate using an ArrayAdapter (custom adapter class). The problem is that the TextView that I have made inside of the list_item.xml is not appearing. This is strange because in this xml I also created an ImageView and that is showing up. Here is my code:
FontList.java
lv = (ListView) findViewById(R.id.listView1);

ArrayList<String> fontList = new ArrayList<String>();

    try {
      BufferedReader br = new BufferedReader(new InputStreamReader(getAssets().open("fonts.txt")));

      String line = br.readLine();
      while (line != null) {
            fontList.add(line);
            line = br.readLine();
      }
      br.close();
    }
    catch (IOException e) {
      e.printStackTrace();
    }

ArrayAdapter<String> adapter = new CustomAdapter(this, R.layout.list_item, R.id.fontTextView, fontList);        
lv.setAdapter(adapter); 

CustomAdapter.java
public class CustomAdapter extends ArrayAdapter<String> {
Context context;
int layoutResourceId;
int textViewResourceId;
ArrayList<String> data = new ArrayList<String>();

public CustomAdapter(Context context, int layoutResourceId, int textViewResourceId, ArrayList<String> fontList) {

    super(context, layoutResourceId,textViewResourceId, fontList);
    this.layoutResourceId = layoutResourceId;
    this.textViewResourceId = textViewResourceId;
    this.context = context;
    this.data = fontList;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View row = convertView;

    LayoutInflater inflater = ((Activity) context).getLayoutInflater(); 
    row = inflater.inflate(layoutResourceId, parent, false);

    String item = data.get(position);
    ImageView ib = (ImageView)row.findViewById(R.id.alreadyDownloaded);
    TextView textView = (TextView)row.findViewById(R.id.fontTextView);

    if (item.equals("Aleo") ){ //this is working properly so the arraylist is populated
        ib.setVisibility(View.INVISIBLE);
    }    

    return row;
}

list_item.xml
    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/fontTextView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:layout_marginRight="20dp"
        android:layout_weight="0.5"
        android:fontFamily="sans-serif-light"
        android:gravity="center_vertical"
        android:minHeight="?android:attr/listPreferredItemHeight"
        android:paddingLeft="6dip"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textStyle="normal" />

    <ImageView
        android:id="@+id/alreadyDownloaded"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="80dp"
        android:layout_weight="0.5"
        android:gravity="center_vertical"
        android:paddingLeft="6dip"
        android:src="@drawable/ic_action_accept" />

</LinearLayout>

Does anyone know why the fontTextView isnt showing up? The rest of the ListView seems fine. The only problem is there is no text.

A:

This is because your custom ArrayAdatper will set the default font color to white, and if your background color is also white, you will not actually see the text.
Try changing either the background color or font color like this in your .xml file. You can change your background color like this.
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/sample"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="#028dbe"
          android:ellipsize="end"
          android:maxLines="5"/>

