Dodaj przycisk do PrefrenceScreen: Android

Cześć Chcę dodać przycisk do prefrencescreen, udało mi się dodać przycisk do prerence, ale nie mogłem uzyskać zdarzenia onClick. załączyłem mój kod do ekranu preence

setting.xml

<code><PreferenceCategory android:title="Application Details">

    <Preference android:key="type" 
                android:title="Type"
                android:summary="" />

</PreferenceCategory>

<PreferenceCategory android:title="Notification Settings">

    <ListPreference android:key="sendNotificationType"
                    android:title="Status Notification For"
                    android:dialogTitle="Status Notification For" />

</PreferenceCategory>
</code>

settingdetail.xml

<code><TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_alignRight="@+id/textView2"
    android:layout_marginLeft="15dp"
    android:text="Type"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/textView1"
    android:layout_marginLeft="15dp"
    android:layout_toLeftOf="@+id/setFromTimeBtn"
    android:text="Summary"
    android:textAppearance="?android:attr/textAppearanceSmall" />

<Button
    android:id="@+id/buyItNowBtn"
    android:layout_width="80dp"
    android:layout_height="30dp"
    android:layout_alignParentRight="true"
    android:layout_marginRight="15dp"
    android:layout_centerVertical="true"
    android:background="@drawable/button"
    android:text="@string/buyItNowBtnTxt"
    android:textColor="@color/white" />
</code>

i metoda onCreate klasy prefenceActivity

<code>protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.layout.setting);
    setContentView(R.layout.settingview);

    Preference typePref = (Preference) findPreference("type");
    typePref.setLayoutResource(R.layout.settingdetail);
typePref.setSelectable(true);

    Button btn = (Button) findViewById(R.id.buyItNowBtn);
    btn.setOnClickListener(new OnClickListener() {

    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        Log.e(TAG,"TEST");
        Toast.makeText(Setting.this, "TEST", Toast.LENGTH_SHORT).show();
    }
});

}
</code>

zrzut ekranu

questionAnswers(5)

yourAnswerToTheQuestion