getChildAt() 调用目标异常

getChildAt() InvocationTargetException

在row_layout的xml中我设置了一个删除按钮如下

row_layout.xml

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rowlayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginTop="0dp"
    android:background="#ffffff"
    android:baselineAligned="false"
    android:orientation="horizontal"
    android:paddingLeft="10sp"
    android:weightSum="100" >

    <LinearLayout
        android:id="@+id/Layout"
        android:layout_width="150sp"
        android:layout_height="50dp"
        android:layout_weight="90"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/firstTextView"
            android:layout_width="150sp"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_marginTop="10sp"
            android:gravity="top"
            android:text="Activity"
            android:textColor="#000" />

        <TextView
            android:id="@+id/firstTextView2"
            android:layout_width="150sp"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:gravity="top"
            android:text="Sub-Activity"
            android:textColor="#000" />
    </LinearLayout>

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"

        android:src="@drawable/edit" />

    <ImageView
        android:id="@+id/delete"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         android:clickable="true"
        android:onClick="onClickDelete"
        android:src="@drawable/neg" />

</LinearLayout>

这里是onClickDelete方法

    public void onClickDelete(View v) 
{


    ListView lvItems = getListView();

    //get the row the clicked button is in
    LinearLayout vwParentRow = (LinearLayout)v.getParent();

    TextView child = (TextView) vwParentRow.getChildAt(0);
    child.setText("Delete Clicked");


}

当我按下删除键时,它在 (TextView child = (TextView) vwParentRow.getChildAt(0);)

处显示 invocationtargetexception

抱歉,这是一个非常基本的错误。我是 android 的新手。 谢谢你的回复。

比较好

TextView child = (TextView)findViewById("yourtextfieldIDHere");
child.setText("Delete Clicked");