14 Feb 2013, 23:26
Generic-user-small

Thomas Gooderham (4 posts)

Hi got to section 3.8 and cannot sort out an error which I believe is associated with the following line in Prefs.java, as settings can not be resolved.

addPreferencesFromResource(R.xml.settings);

Eclipse then puts a line through the addPreferencesFromResource, with further investigation suggesting that this Is deprecated.. Can’t work out what to do? Any answers appreciated.

15 Feb 2013, 08:29
Generic-user-small

Anthony Shaw (131 posts)

Probably nothing to do with addPreferencesFromResource() being deprecated. Check that the settings.xml was actually called res/xml/settings.xml, if you gave it a different name or put it in a different folder then it cannot be resolved.

15 Feb 2013, 13:47
Generic-user-small

Thomas Gooderham (4 posts)

Hi,

yes I checked and double checked that the settings.xml file was located correctly (and remember having to create the xml folder within res in order to create settings.xml)

16 Feb 2013, 15:04
Generic-user-small

Anthony Shaw (131 posts)

The next thing you need to check is that there are no errors in any of your xml or layout files as this will cause R.java to not be generated and so the R.xml.settings will not exist. Do a project clean and look in the build results to find the errors.

01 Mar 2013, 21:58
Generic-user-small

David Pead (1 post)

@Thomas - you are correct, the method has been marked as deprecated. However it should still compile and run.

See Ed’s comment “here”: http://forums.pragprog.com/forums/152/topics/10708

14 Apr 2013, 02:27
Burnette_ed_pragsmall

Ed Burnette (1316 posts)

You don’t have to do anything, in fact you have to use the deprecated method unless you change your program to use Fragments.

Using Fragments will make your program not work on Android 2.x and earlier unless you also switch to use the Fragments inside the Android compatibility library. See:

  • http://developer.android.com/tools/extras/support-library.html

Fragments are a somewhat advanced topic. For a little program like Sudoku there’s no reason to use Fragments. You only need them if you want to display a different UI in different screen sizes (like tablets) and orientations. See:

  • http://developer.android.com/training/basics/fragments/index.html
  You must be logged in to comment