title: listview with edittext ,checkbox and textView in android
body: <p>i have created a listview with checkbox,edittext and textview.<br>
  data is populated in listview with sql server. but i am not being able to use   <code>onCheckedChangedListener</code> on checkbox. so that on clicking the checkbox corresponding data of textview and edittext is not being saved..  </p>
  
  <p>i know i am doing mistake somewhere in my adapter class..  </p>
  
  <p>How to save data and what logic should i use in <code>onCheckedChangedListener</code> in my adapter class?</p>
  
  <p>code for pojo class</p>
  
  <pre><code>public class Model {
  
   public String name="";
      public boolean selected=false;
      public String score="";
  
      public Model(String name) { 
         this.name = name;  
         selected = false;
          score="";          
     }
              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;    
       }
  
      public String getScore() {     
      return score;    
      }
  
      public void setScore(String score) {
          this.score = score;  
          }
      }
  </code></pre>
  
  <p>code for Adapter class</p>
  
  <pre><code>public class MyAdapter extends ArrayAdapter&lt;Model&gt; {
  
  private final List&lt;Model&gt; list;   
  private final Activity context;
  
  public MyAdapter(Activity context, List&lt;Model&gt; list)
  {
     super(context, R.layout.row, list);  
     this.context = context;       
     this.list = list;   
      }
  
  static class ViewHolder
  {        
      protected TextView text; 
      protected CheckBox checkbox;        
      protected EditText scores;    
  }
  
  @Override   
  public View getView(int position, View convertView, ViewGroup parent)
  {        
      View view = null;   
      if (convertView == null)
      {            
          LayoutInflater inflator = context.getLayoutInflater(); 
  
          view = inflator.inflate(R.layout.row, null); 
  
          final ViewHolder viewHolder = new ViewHolder(); 
          viewHolder.text = (TextView) view.findViewById(R.id.label);    
          viewHolder.scores=(EditText) view.findViewById(R.id.txtAddress);      
          viewHolder.scores.addTextChangedListener(new TextWatcher()
          {  
              public void onTextChanged(CharSequence s, int start, int before, int count) {      
                  Model element=(Model)viewHolder.scores.getTag();    
                  element.setScore(s.toString());        
              }        
              public void beforeTextChanged(CharSequence s, int start, int count,int after)
              {       
              }      
              public void afterTextChanged(Editable s)
              {                              
              }
              });         
          viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check);  
          viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
              public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {   
                  Model element = (Model) viewHolder.checkbox.getTag(); 
  
                  element.setSelected(buttonView.isChecked()); 
  
  
  
                  }         
              }); 
          viewHolder.checkbox.setTag(list.get(position));      
          viewHolder.scores.setTag(list.get(position));
          view.setTag(viewHolder);   
      }
      else
      {
          view = convertView; 
          ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position));  
          ((ViewHolder) view.getTag()).scores.setTag(list.get(position));   
          }                 
          ViewHolder holder = (ViewHolder) view.getTag();     
          holder.text.setText(list.get(position).getName());    
          holder.scores.setText(list.get(position).getScore());      
          holder.checkbox.setChecked(list.get(position).isSelected());     
          return view;
  
   } 
  
  }
  </code></pre>
  
  <p>code for MainActivity class</p>
  
  <pre><code>public class MainActivity extends Activity { 
  ListView listView;
   Button btnSave;
   Connection connect;
      ArrayAdapter&lt;Model&gt; adapter;
      MyConnection mycon;
      List&lt;Model&gt; list = new ArrayList&lt;Model&gt;();
      List&lt;String&gt;data=new ArrayList&lt;String&gt;();
      List&lt;String&gt;data2=new ArrayList&lt;String&gt;();
      StringBuilder sb;
  
  
  
      public void onCreate(Bundle icicle) {
          super.onCreate(icicle);
          setContentView(R.layout.main);
          mycon=new MyConnection(getApplicationContext());
          listView = (ListView) findViewById(R.id.my_list);
          btnSave = (Button)findViewById(R.id.btnSave);
          sb=new StringBuilder();
          adapter = new MyAdapter(this,getModel());
  
          listView.setAdapter(adapter);
          if(list.isEmpty()){
              Toast.makeText(getApplicationContext(), "kuldeep", Toast.LENGTH_LONG).show();
          }
  
          btnSave.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
  
                  for (int i = 0; i &lt; list.size(); i++) {
                     Toast.makeText(getBaseContext(), "Name : "+list.get(i).getName() +" Selected: "+list.get(i).isSelected()+"address: "+list.get(i).getScore().toString(), Toast.LENGTH_SHORT).show();
  
                  }
  
              }
          });
              }
  
  
      private List&lt;Model&gt; getModel() {
          list.clear();
          try{
          Statement smt=mycon.connection().createStatement();
          ResultSet rs=smt.executeQuery("WORKINGTYPE");
          while(rs.next()){
              list.add(new Model(rs.getString("FIELD_NAME")));
          }
          }catch(Exception e){
              e.printStackTrace();
          }
  
                  /*  list.add(new Model("kuldeep"));
                      list.add(new Model("sandeep"));
                      list.add(new Model("ravi"));
                      list.add(new Model("pradeep"));
                      list.add(new Model("praveena"));
                      list.add(new Model("ruchi"));
                      list.add(new Model("vikas"));
                      list.add(new Model("sonu"));
                      list.add(new Model("ashu"));
  
          */
  
                  return list;
      }
      }
  </code></pre>
  
  <p>for saving data of textview and EditText what logic should i use and where in Adapter clss i should write it..</p>