title: ListView using custom adapter.
body: <p>I am fetching the data form sql database and retrieving it using JSON</p>
  
  <pre><code>try {
          JSONObject jsonObj = new JSONObject(myJSON);
          peoples = jsonObj.getJSONArray("result");
  
          ArrayList&lt;String&gt; personList=null;
          for (int i = 0; i &lt; peoples.length(); i++) {
  
              JSONObject c = peoples.getJSONObject(i);
              String roll = c.getString(TAG_ROLL);
  
              personList = new ArrayList&lt;String&gt;();
              personList.add(i, roll);
       }
          dataAdapter = new MyCustomAdapter(this, R.layout.list_item, persons);
          ListView listView = (ListView) findViewById(R.id.listView);
          listView.setAdapter(dataAdapter);
  </code></pre>
  
  <p>Now, When I am passing the data to MyCustomAdapter class, the arraylist needs to change from String to type Student(Which is a class)</p>
  
  <p>MyCustomAdapter.java</p>
  
  <pre><code> public class MyCustomAdapter extends ArrayAdapter {
  public ArrayList&lt;Student&gt; personList;
  public MyCustomAdapter(Context context, int resource, ArrayList&lt;Student&gt; personList) {
      super(context, resource, personList);
      this.personList=new ArrayList&lt;Student&gt;();
      this.personList.addAll(personList);
  }
  
  private class ViewHolder{
      TextView roll;
      TextView name;
      CheckBox check;
  }
  
  
  public View getView(int position, View convertView, ViewGroup parent){
      ViewHolder holder=null;
      Log.v("ConvertView", String.valueOf(position));
  
      if(convertView==null){
          LayoutInflater vi = (LayoutInflater)getSystemService(
                  Context.LAYOUT_INFLATER_SERVICE);
          convertView = vi.inflate(R.layout.list_item, null);
  
          holder=new ViewHolder();
          holder.roll=(TextView)convertView.findViewById(R.id.roll);
          holder.name=(TextView)convertView.findViewById(R.id.name);
          holder.check=(CheckBox)convertView.findViewById(R.id.checkBox);
          convertView.setTag(holder);
  
          holder.name.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  CheckBox cb=(CheckBox) v;
                  Student student=(Student)cb.getTag();
                  Toast.makeText(getContext(), "Clicked on Checkbox: " + cb.getText() +
                          " is " + cb.isChecked(), Toast.LENGTH_SHORT).show();
                  student.setSelected(cb.isChecked());
  
              }
          });
      }
      else{
          holder=(ViewHolder)convertView.getTag();
      }
  
      Student student=personList.get(position);
      holder.roll.setText(" (" +  student.getRollno() + ")");
      holder.name.setText(student.getName());
      holder.check.setChecked(student.isSelected());
      holder.check.setTag(student);
  
      return convertView;
  
  }
  }
  </code></pre>
  
  <p>Student.java</p>
  
  <pre><code>  public class Student {
  String rollno;
  String name;
  Boolean selected;
  
  public Student(String rollno, String name, Boolean selected){
      super();
      this.rollno=rollno;
      this.name=name;
      this.selected=selected;
  }
  public String getRollno(){
      return rollno;
  }
  public void setRollno(String rollno){
      this.rollno=rollno;
  }
  
  public String getName(){
      return name;
  }
  public void setName(String name){
      this.name=name;
  }
  public Boolean isSelected(){
      return selected;
  }
  public void setSelected(boolean selected) {
      this.selected = selected;
  }
  }
  </code></pre>
  
  <p>How should I be passing data to my custom adapter?</p>