I'm using PreferenceFragment with some default preferences categories and one custom layout:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
    <PreferenceCategory
        android:key="first_category"
        android:title="config" >
        <EditTextPreference
            android:defaultValue="example"
            android:dialogMessage="text"
            android:dialogTitle="Title"
            android:key="mykey"
            android:summary="summary"
            android:title="title" />
        <Preference
            android:key="test_connection"
            android:title="Test connection"
            android:layout="@layout/test_conn"  />
 </PreferenceCategory>
</PreferenceScreen>
My test_conn layout:
   <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="6dip"
    android:layout_marginLeft="15dip"
    android:layout_marginRight="6dip"
    android:layout_marginTop="6dip"
    android:layout_weight="1" >
    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="20dp"
        android:ellipsize="marquee"
        android:fadingEdge="horizontal"
        android:text="Test connection"
        android:textAppearance="?android:attr/textAppearanceLarge" />
    <TextView
        android:id="@+id/summary"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginRight="20dp"
        android:ellipsize="marquee"
        android:fadingEdge="horizontal"
        android:text="Ko"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#ff0000"
        android:textStyle="bold" />
</RelativeLayout>
I'm reading the textview R.id.summary with this code:
        addPreferencesFromResource(R.xml.preferences);
        findPreference(TEST_CONN).setOnPreferenceClickListener(this);    
        Preference custom = findPreference(TEST_CONN);
        customv = custom.getView(null, null);
        res = (TextView) customv.findViewById(R.id.summary);
I can read correctly my TextView, but if I try to change the text, for example inside an asynctask, I can't see the text changed.
This is a part of asynctask:
        @Override
    protected void onPostExecute(Boolean result) {
        if (result == true){
            res.setText("Ok");
            res.setTextColor(Color.GREEN);
        }
        else {
            res.setText("Ko");
            res.setTextColor(Color.RED);
        }
        pdia.dismiss();
    }
When the user click on the preference "test_connection", an asynctask starts and in the funzion onPostExecute I modify the text, but doesn't work. Am I missing something? Should I read the textview with another method?