title: Add custom layout to listview row
body: <p>I have tried for a while now but I still can't seem to get it right. I can add a custom header to a listview but I can't add a custom row layout to a list. I want each row in the list to have the layout of the file "listitemrow.xml" but I can't seem to quite understand how to do that despite reading multiple tutorials.</p>
  
  <p>Here is my code</p>
  
  <pre><code>public class PortfolioFragMent extends android.app.ListFragment{
      private String[] ShareholdingNames;
      private ListView mainListView ;
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
  
          ListView listView = new ListView(getActivity());
          super.onCreate(savedInstanceState);
  
          ViewGroup header = (ViewGroup)inflater.inflate(R.layout.listviewheader, listView, false);
          listView.addHeaderView(header, null, false);
  
          ViewGroup listrow = (ViewGroup)inflater.inflate(R.layout.listitemrow, listView, false);
  //listView.add(listitemrow); I want to do something like this
  
          ArrayAdapter&lt;String&gt; array = new ArrayAdapter&lt;String&gt;(getActivity(),
                  android.R.layout.simple_list_item_1);
          setListAdapter(array);
          ShareholdingNames= ShareholdingNames();
  
          for (String str : ShareholdingNames)
              array.add(str);
          listView.setAdapter(array);
          return listView;
      }
  
      private String[] ShareholdingNames(){
          ShareholdingNames = new String[Portfolio.getPortfolio().count()];
          for(int i=0; i &lt; Portfolio.getPortfolio().count(); i++){
              ShareholdingNames[i]= Portfolio.getPortfolio().getShareHolding(i).getName();
          }
          return ShareholdingNames;
      }
  
      public void onListItemClick(ListView l, View v, int position, long id) {
          Intent intent = new Intent(getActivity().getApplicationContext(),
          DetailShareHoldingActivity.class);
          intent.putExtra("new_variable_name","value");
          intent.putExtra("bookPositionInList",position);
          startActivity(intent);  
      }
  }
  </code></pre>