Cannot find TextView in PreferenceActivity

坚强是说给别人听的谎言 提交于 2019-12-06 07:34:36

Preference.setLayoutResource() only updates the internal reference that preference has to a layout ID, it does not actually update the layout to redisplay. Therefore the TextView you are looking for with findViewById() is not inflated for your use. The only place Preferences inflate their layouts is when created.

You'll either need to have that custom layout set at the start (before addPreferencesFromResource() inflates everything), or adjust the title/summary properties of the existing preference instead to set your "Registration Successful" string. Also, if you are using a custom preference layout, make sure you're following the rules set forth in the SDK Documentation.

Hope that Helps!

Maybe because you calls findViewById of your Activity instead of calling same method of registrationStatus object.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!