Skip to content

Instantly share code, notes, and snippets.

@davetrux
Created March 28, 2013 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davetrux/5260231 to your computer and use it in GitHub Desktop.
Save davetrux/5260231 to your computer and use it in GitHub Desktop.
Another static Android API example
@SuppressWarnings("deprecation")
public class Settings extends PreferenceActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB )
addPreferencesFromResource(R.xml.settings);
else
addPreferencesAPIv11();
}
private void addPreferencesAPIv11() {
getFragmentManager().beginTransaction().replace(android.R.id.content, new PrefFragment()).commit();
}
public static class PrefFragment extends PreferenceFragment
{
@Override
public void onCreate(final Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment