title: Android: Customize list view, Table view in adapter
body: <p>I created a table view in list view adapter programmatically. For that first i created a Adapter layout as :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@android:color/black"
      android:stretchColumns="*"
      android:id="@+id/tablelayout" &gt;
  &lt;/ableLayout&gt;
  </code></pre>
  
  <p>Then what I have done in the adapter is:</p>
  
  <pre><code>public class DemoAdapter extends ArrayAdapter&lt;String&gt; {
      //Global Variable declaration
      Context myContext;
      String[] key, value, loop;
  
      public DemoAdapter(Context context, String[] key, String[] value, String[] loop){
          super(context, R.layout.demo_screen_adapter, loop);
          this.myContext = context;
          this.key = key;
          this.value = value;
          this.loop = loop;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent){
          View row = convertView;
          if (row == null){
              // get reference to the activity
              LayoutInflater inflater = ((Activity) myContext).getLayoutInflater();
              // Inflate the custom text which will replace the default text view
              //list_item is a simple linear layout which contain textView1 in it. 
              row = inflater.inflate(R.layout.demo_screen_adapter, parent, false);
          }
  
          TableLayout tableLayout = (TableLayout) row.findViewById(R.id.tablelayout);
          for(int i=0; i&lt;5; i++){
              TableRow tableRow = new TableRow(myContext);
              tableRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
  
              TextView tvKey = new TextView(myContext);
              tvKey.setText(key[(position*5)+i]);
              tvKey.setTextColor(Color.WHITE);
              tvKey.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
              tableRow.addView(tvKey);
  
              TextView tvValue = new TextView(myContext);
              tvValue.setText(value[(position*5)+i]);
              tvValue.setTextColor(Color.WHITE);
              tvValue.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
              tableRow.addView(tvValue);
              tableLayout.addView(tableRow, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT));
          }
          return row;
      }
  }
  </code></pre>
  
  <p>This is working good. In my each list item there is a table view contains around two column and five rows.</p>
  
  <p>Now the <strong>issue</strong> is:</p>
  
  <p>I want to fetch the perticular values on click of list item. I am not able to do so.
  What i tried  as:</p>
  
  <pre><code>@Override
  public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position, long arg3) {
      Toast.makeText(this, ""+(String) arg0.getItemAtPosition(position), Toast.LENGTH_LONG).show();
  }
  </code></pre>
  
  <p>But it shows the position on which i click.</p>
  
  <p>What should i do for that please guide me.</p>