I have a preference screen and i am specifying a layout resource using the android:layout attribute. In the preference activity i am using/inflating the preference using addPreferencesFromResource from onCreate method. Inside the layout i have few textviews and buttons.

The problem is i am unable to find any of the textviews, checkboxes and buttons using findViewById method ! Every result for findViewById returns null.

EDIT:

I need to attach a listener to the checkbox.

Can anyone please help me over here ?

EDIT 2:

1) preference_layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="33dp"
    android:gravity="center_vertical"
    android:minHeight="33dp"
    android:id="@+id/preference_header_switch_item_responder_layout"
    style="?android:attr/listSeparatorTextViewStyle" >

    <CheckBox
    android:id="@+id/switchWidget"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:clickable="true"
    android:focusable="false"
    android:padding="8dip"
    android:layout_marginRight="14dip" />
</LinearLayout>

2) preference screen

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >

    <Preference
        android:defaultValue="false"
        android:key="auto_responder_key"
        android:widgetLayout="@layout/preference_layout"
        android:title="@string/auto_responder">
    </Preference>

</PreferenceScreen>

3)Preference Activity onCreate:

EDIT 3:

@Override
    protected void onCreate(Bundle savedInstanceState)
    {
  
Edit
Report