title: Displaying an arrow in list items
body: <p>I have a ListView in a fragment, and I want to display an arrow at the right of every list item. I followed this tutorial: <a href="http://willvk.blogspot.it/2011/07/adding-arrow-image-to-right-of-listview.html" rel="nofollow">http://willvk.blogspot.it/2011/07/adding-arrow-image-to-right-of-listview.html</a> but the only thing I see when I open my fragment is a blank page. Here's my code:</p>
  
  <pre><code>public class MyFragment extends ListFragment {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
  
          String[] values = new String[] { "Item1", "Item2", "Item3",
          "Item4"};
  
          boolean[] listImages={true, true, true, true, true};
          setListAdapter(new CustomAdapter(getActivity(), R.layout.fragment_my, R.id.text1, R.id.image1, values, listImages ));
  
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          return inflater.inflate(R.layout.fragment_my, container, false);
      }
  
      @Override
      public void onListItemClick(ListView list, View v, int position, long id) {
          Intent intent = null;
          switch(position) {
          case 0:
              intent = new Intent(getActivity(), Item1Activity.class);
              break;
          case 1:
              intent = new Intent(getActivity(), Item2Activity.class);
              break;
          case 2:
              intent = new Intent(getActivity(), Item3Activity.class);
              break;
          case 3:
              intent = new Intent(getActivity(), Item4Activity.class);
              break;
  
          }
          startActivity(intent);
      }
  }
  </code></pre>
  
  <p>CustomAdapter.java</p>
  
  <pre><code>public class CustomAdapter extends ArrayAdapter&lt;String&gt;
  {
      Activity context;
      String[] items;
      boolean[] arrows;
      int layoutId;
      int textId;
      int imageId;
  
      public CustomAdapter(Activity context, int layoutId, int textId, int imageId, String[] items, boolean[] arrows)
      {
          super(context, layoutId, items);
  
          this.context = context;
          this.items = items;
          this.arrows = arrows;
          this.layoutId = layoutId;
          this.textId = textId;
          this.imageId = imageId;
      }
  
      public View getView(int pos, View convertView, ViewGroup parent)
      {
          LayoutInflater inflater=context.getLayoutInflater();
          View row=inflater.inflate(layoutId, null);
          TextView label=(TextView)row.findViewById(textId);
  
          label.setText(items[pos]);
  
          if (arrows[pos])
          {
           ImageView icon=(ImageView)row.findViewById(imageId); 
              icon.setImageResource(R.drawable.arrow);
          }   
  
          return(row);
      }
  </code></pre>
  
  <p>fragment_my.xml</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:paddingLeft="8dp"
      android:paddingRight="8dp" &gt;
  
      &lt;ListView
          android:id="@id/android:list"
          android:layout_width="match_parent"
          android:layout_height="0dp" /&gt;
  
      &lt;TextView
          android:id="@+id/text1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:padding="10dp"
          android:textSize="16sp"
          android:typeface="sans" /&gt;
  
      &lt;ImageView
          android:id="@+id/image1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentRight="true" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>