title: getting values of the row on a button click which is in that row
body: <p>My android app is populating a table layout which is created programmatically from the sqlite database.the last column of the table layout has two buttons. those two buttons are assigned to one column by a linear layout.</p>
  
  <pre><code>LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                      35, 35);
  
              params.setMargins(10, 0, 10, 0);
              seventhCol1=new Button(this);
              seventhCol1.setText("A");
              seventhCol1.setLayoutParams(params);
              //seventhCol1.setLayoutParams(new LayoutParams(30, 30));
              seventhCol1.setId(71);
              seventhCol1.setOnClickListener(mListener);
  
              seventhCol2=new Button(this);
              seventhCol2.setText("C");
              seventhCol2.setLayoutParams(params);
              seventhCol2.setId(72);
              seventhCol2.setOnClickListener(nListener);
  
              btn_linear=new LinearLayout(this);
              btn_linear.setOrientation(LinearLayout.HORIZONTAL);
              btn_linear.addView(seventhCol1);
              btn_linear.addView(seventhCol2);
              btn_linear.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
              btn_linear.setGravity(Gravity.CENTER);
              tr.addView(btn_linear);
  </code></pre>
  
  <p>on click of the button <code>seventhCol1</code> i want to get the data from the particular row from where that button was clicked...how can I do that????
  I tried doing it by this method:</p>
  
  <pre><code>tr.setOnClickListener(rowclickListner);
  
  private OnClickListener rowclickListner=new OnClickListener() {
  
      @Override
      public void onClick(View v) {
  
  
  // TODO Auto-generated method stub
      TableLayout tl=(TableLayout) v.getParent();
      /*TableRow tr=(TableRow) tl.getParent();*/
      TableRow tr=(TableRow) tl.getParent();
      TextView tv_mobile=(TextView)tr.getChildAt(2);
      String mobile=tv_mobile.getText().toString();
  
      Toast.makeText(LeadManagement.this, mobile, Toast.LENGTH_LONG).show();
      /*ArrayList&lt;String&gt; leaddetails=mDbHelper.getTableDetails("lead_table", mobile);
       prefEditor.putBoolean("leadbundle", true);
       prefEditor.commit();
       startActivity(new Intent(LeadManagement.this,CreateLead.class).putExtra("leadlist", leaddetails));*/
      }
  };
  </code></pre>
  
  <p>but it is showing an error!! how can i do it?</p>