I am trying to access a button from another xml file which is used for customizing each row in my list. But how can I do this as I am getting a nullpointer exception while setting the onClick listener. My code is shown below.main.xml\[code\]<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" androidrientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ListView android:id="@+id/List" android:layout_width="fill_parent" android:layout_height="fill_parent"/></LinearLayout>\[/code\]row.xml\[code\]<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"androidrientation="horizontal"android:layout_width="fill_parent"android:layout_height="fill_parent"android:id="@+id/list_item"><TextViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:id="@+id/list_item_text_view"android:textSize="20sp"androidadding="10dp"android:layout_weight="1"android:layout_marginLeft="35dp" /><Button android:id="@+id/b1"android:layout_width="wrap_content"android:layout_height="wrap_content"/>\[/code\]this my activity class\[code\]protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);Button b1 = (Button)findViewById(R.id.b1);b1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub } });\[/code\]So basically how to set a onclicklistener to a b1 of row.xml while the activity view is set on main.xml