Need Help in Firing TableRow Event in Android?
<p>Hai Friends,
          I want to invoke or fire the onclick event for Table Row when the user clicked a particular table row in the UI.
This is my xml code </p>

<pre><code>  &lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/table_bars" android:layout_width="wrap_content" android:layout_height="fill_parent"android:background="@drawable/corner" android:stretchColumns="1" android:layout_margin="10dp"&gt;
  &lt;TableRow&gt;
  &lt;TextView android:id="@+id/barsp_baradd_value"
  android:textSize="15sp" android:padding="10dp" android:layout_width="wrap_content" /&gt;
   &lt;/TableRow&gt;
   &lt;View android:layout_height="1dp" android:background="#FF909090" /&gt;
   &lt;TableRow&gt;
   &lt;TextView android:id="@+id/barsp_barphone_value"
             android:textSize="15sp"    android:padding="10dp" android:layout_width="wrap_content" /&gt;
    &lt;ImageView android:id="@+id/san_arrow2" android:src="@drawable/newforward" android:layout_alignParentRight="true"
android:adjustViewBounds="true" android:layout_marginTop="10dp"
android:layout_width="30dp"  android:layout_height="35dp" android:paddingRight="4dp" /&gt;
 &lt;/TableRow&gt;
  &lt;View android:layout_height="1dp" android:background="#FF909090" /&gt;
  &lt;TableRow android:id="@+id/barsite"&gt;
   &lt;TextView android:id="@+id/barsp_barsite_value"
  android:textSize="15sp" android:padding="10dp" android:layout_width="wrap_content" /&gt;
&lt;ImageView android:id="@+id/san_arrow3" android:src="@drawable/newforward" android:layout_alignParentRight="true"
android:adjustViewBounds="true" android:layout_marginTop="10dp"
android:layout_width="30dp"  android:layout_height="35dp" android:paddingRight="4dp" /&gt;
                  &lt;/TableRow&gt;

                &lt;/TableLayout&gt;
</code></pre>

<p>and my Java code is</p>

<pre><code>TableRow row = (TableRow)findViewById(R.id.row1);

                row.setOnClickListener(new OnClickListener() {



                                @Override
                 public void onClick(View v) {

                                // TODO Auto-generated method stub

                                try {

                                        //Log.v(TAG, "try");

                                        uri = Uri.parse("geo:0,0?q=" + VALUE_baraddress1[0] + ", "

                                                        + VALUE_baraddress2[0] + ", "

                                                        + VALUE_baraddress3[0]);

                                        //Log.v(TAG, VALUE_baraddress1[0] + ", "

                                                //      + VALUE_baraddress2[0] + ", "

                                                //      + VALUE_baraddress3[0]);

                                       startActivity(new Intent(Intent.ACTION_VIEW, uri));

                                } catch (Exception e) {

                                        //Log.v(TAG, "catch");

                                        uri = Uri.parse("geo:0,0?q=" + VALUE_baraddress1[0] + ", "

                                                        + VALUE_baraddress3[0]);

                                        //Log.v(TAG, VALUE_baraddress1[0] + ", "

                                        //              + VALUE_baraddress3[0]);

                                        startActivity(new Intent(Intent.ACTION_VIEW, uri));



                                }



                        }

                });



i had got null pointer exception in this line

TableRow row = (TableRow)table.getChildAt(0);
</code></pre>

<p>Logcat Messages</p>

<pre><code>11-10 15:47:04.164: ERROR/AndroidRuntime(12720):     ... 11 more
11-10 15:47:04.164: ERROR/AndroidRuntime(12720): Caused by: java.lang.NullPointerException
11-10 15:47:04.164: ERROR/AndroidRuntime(12720):     at com.fsp.blacksheep.BS_Bars.onCreate(BS_Bars.java:546)
11-10 15:47:04.164: ERROR/AndroidRuntime(12720):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
11-10 15:47:04.164: ERROR/AndroidRuntime(12720):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
11-10 15:47:04.164: ERROR/AndroidRuntime(12720):     ... 19 more
11-10 15:47:06.324: ERROR/JavaBinder(972): !!! FAILED BINDER TRANSACTION !!!
</code></pre>
