can not find TextView in PreferenceActivity


  1. vovs

    vovs Active Member

    Hi, guys. In my PreferenceActivity I have some Preferences. One I inflate from layout:

    Code (Text):
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            addPreferencesFromResource(R.layout.settings);
    ...
    }

    protected void onResume() {    
            super.onResume();
    Preference registrationStatus = (Preference) findPreference("registrationStatusPref");
     if (!TextUtils.isEmpty(somestring){
                registrationStatus.setLayoutResource(R.layout.push_reg_status);
                TextView push_reg_status_txt = (TextView)findViewById(R.id.pushRegTxtPref);
     }
    ....
    }
    push_reg_status_txt is TextView from push_reg_status layout, and push_reg_status always is null.

    push_reg_status layout

    Code (Text):
    ....
    <TextView
            android:id="@+id/pushRegTxtPref"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="2dp"
            android:layout_marginBottom="4dp"
            android:text="Registration Succesful"
            android:textColor="#99ff33"
            android:gravity="center_horizontal"
            android:layout_gravity="center_horizontal"/>
    .....

    Why?

    Advertisement
    :
Loading...

Share This Page