onclick is only invoked after second time for dynamically inflated rows android
<p>I am dynamically creating a table. I am inflating the rows using another layout file.
But the onclick event for these dynamic rows is triggered only after the second time. 
Please assist.</p>

<pre><code>private void populateRouteDetails(){

        TableRow row;
        View[] lArray = new View[24];
        View lView = null;
        LayoutParams lLayoutParams = new LayoutParams(
                LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);

        for (int current = 0; current &lt; 24; current++) {
            row = new TableRow(this);                   
            row.setPadding(0, 1, 0, 1);
            LayoutInflater inflator = LayoutInflater.from(getBaseContext());
                // inflate child
                View item = inflator.inflate(R.layout.linear_row, null);
                lArray[current] = item;     
                item.setPadding(0, 15, 0, 15);
                row.addView(item);
                row.setGravity(Gravity.CENTER_HORIZONTAL);
            busRoute.addView(row, lLayoutParams);
            lView = new View(this);
            lView.setBackgroundColor(0xFF00FF00);
            busRoute.addView(lView,
             new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, 1));
        }
        for(int lCount = 0;lCount&lt;lArray.length;lCount++){
            View lRow = lArray[lCount];
            lRow.setClickable(true);
            lRow.setFocusable(true);
            lRow.setFocusableInTouchMode(true);

            lRow.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View pView) {                   
                    Toast.makeText(BusDetails.this, "Hello",Toast.LENGTH_SHORT).show();
                }
            });
        }           
    }
</code></pre>
