title: Create listview in fragment android
body: <p>As the title I want to create a listview with custom row in Fragment. My code below.</p>
  
  <p>Fragment class</p>
  
  <pre><code>public class PhotosFragment extends Fragment{
  
  public PhotosFragment(){}
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.fragment_photos, container, false);
  
      ArrayList&lt;ListviewContactItem&gt; listContact = GetlistContact();
      ListView lv = (ListView)getActivity().findViewById(R.id.lv_contact);
      lv.setAdapter(new ListviewContactAdapter(getActivity(), listContact));
  
      return rootView;
  }
  
  private ArrayList&lt;ListviewContactItem&gt; GetlistContact(){
      ArrayList&lt;ListviewContactItem&gt; contactlist = new ArrayList&lt;ListviewContactItem&gt;();
  
      ListviewContactItem contact = new ListviewContactItem();
  
      contact.SetName("Topher");
      contact.SetPhone("01213113568");
      contactlist.add(contact);
  
      contact = new ListviewContactItem();
      contact.SetName("Jean");
      contact.SetPhone("01213869102");
      contactlist.add(contact);
  
      contact = new ListviewContactItem();
      contact.SetName("Andrew");
      contact.SetPhone("01213123985");
      contactlist.add(contact);
  
      return contactlist; 
      }   
  }
  </code></pre>
  
  <p>Adapter class</p>
  
  <pre><code>public class ListviewContactAdapter extends BaseAdapter{
  private static ArrayList&lt;ListviewContactItem&gt; listContact;
  
  private LayoutInflater mInflater;
  
  public ListviewContactAdapter(Context photosFragment, ArrayList&lt;ListviewContactItem&gt; results){
      listContact = results;
      mInflater = LayoutInflater.from(photosFragment);
  }
  
  @Override
  public int getCount() {
      // TODO Auto-generated method stub
      return listContact.size();
  }
  
  @Override
  public Object getItem(int arg0) {
      // TODO Auto-generated method stub
      return listContact.get(arg0);
  }
  
  @Override
  public long getItemId(int arg0) {
      // TODO Auto-generated method stub
      return arg0;
  }
  
  
  public View getView(int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
      ViewHolder holder;
      if(convertView == null){
          convertView = mInflater.inflate(R.layout.contact_item, null);
          holder = new ViewHolder();
          holder.txtname = (TextView) convertView.findViewById(R.id.lv_contact_item_name);          
          holder.txtphone = (TextView) convertView.findViewById(R.id.lv_contact_item_phone);
  
          convertView.setTag(holder);
      } else {
          holder = (ViewHolder) convertView.getTag();
      }
  
      holder.txtname.setText(listContact.get(position).GetName());
      holder.txtphone.setText(listContact.get(position).GetPhone());
  
      return convertView;
  }
  
  static class ViewHolder{
      TextView txtname, txtphone;
  }
  }
  </code></pre>
  
  <p>But when I run the app that display no thing. Could anyone tell me what wrong here and how can I fix it?</p>