1. Check out our companion app, Forums for Android! Download from Google Play

can not find TextView in PreferenceActivity

Discussion in 'Application Development' started by vovs, Apr 18, 2011.

  1. vovs

    vovs Active Member
    Thread Starter
    15

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

    Code (Text):
    1. public void onCreate(Bundle savedInstanceState) {
    2.         super.onCreate(savedInstanceState);
    3.         addPreferencesFromResource(R.layout.settings);
    4. ...
    5. }
    6.  
    7. protected void onResume() {    
    8.         super.onResume();
    9. Preference registrationStatus = (Preference) findPreference("registrationStatusPref");
    10.  if (!TextUtils.isEmpty(somestring){
    11.             registrationStatus.setLayoutResource(R.layout.push_reg_status);
    12.             TextView push_reg_status_txt = (TextView)findViewById(R.id.pushRegTxtPref);
    13.  }
    14. ....
    15. }
    push_reg_status_txt is TextView from push_reg_status layout, and push_reg_status always is null.

    push_reg_status layout

    Code (Text):
    1. ....
    2. <TextView
    3.         android:id="@+id/pushRegTxtPref"
    4.         android:layout_width="wrap_content"
    5.         android:layout_height="wrap_content"
    6.         android:layout_marginTop="2dp"
    7.         android:layout_marginBottom="4dp"
    8.         android:text="Registration Succesful"
    9.         android:textColor="#99ff33"
    10.         android:gravity="center_horizontal"
    11.         android:layout_gravity="center_horizontal"/>
    12. .....

    Why?
     

    Advertisement

Share This Page

Loading...