Jump to content

  1. 0
  2. 0
  3. 0/5

Rate this Topic

- - - - -

[TUT] Sample app that extends PreferenceActivity

  • Please log in to reply

OP JBirdVegas

JBirdVegas

java code monkey

Posted 29 September 2011 - 12:12 PM #1

// DO WHAT THE **** YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
//
// Copyright © 2004 Sam Hocevar <sam@hocevar.net>
//
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long
// as the name is changed.
//
// DO WHAT THE **** YOU WANT TO PUBLIC LICENSE
// TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
//
// 0. You just DO WHAT THE **** YOU WANT TO.

^I love the WTFPL license^

Preference Examples by n00bware

I got tired trying to figure out the docs from
http://developer.and...ge-summary.html
and reading examples of how to display the preferences but no examples of how to use the
values sent

SO I wrote an extremely simple app that shows some of the possible
uses of the standard android frameworks implementation of preferences
AND where and how to //do work

I choose the WTFPL license for good reason I really wanted to people to use these
examples to make their life easier

I kept the string names and method names simple and descriptive (they can be anything)

--> Make note of the branches I placed each preference in it's own branch
the branches are done in order (default branch is main and
was the full example)

Examples in order:
EditTextPreference ~/\~ https://github.com/n...tTextPreference
ListPreference ~{-}~ https://github.com/n.../ListPreference
CheckBoxPreference ~\/~ https://github.com/n...ckBoxPreference
master === https://github.com/n...ps_PrefExamples

OK now I was going to do all the code here but I wanted to give a full example people could just download and compile

I'm happy to entertain questions/comments here and maybe provide some more code if anyone
has questions

This is a super simple example and in the code I left lots of comments to explain what was going on

I also seperated the code into branches so everyone has easy to follow commits as examples they
can use.

Attached as the sample app. The strings are named for their string names so everyone can find them easily (that doesn't sound clear but you will see when you look @ res/values/strings.xml)


JBirdVegas

Attached Files


  • 1 Likes

Show Your appreciation by clicking Thanks!

I co-maintain the droid2 branch of CyanogenMod, n00bware founder and lead developer and a developer for AOKP
my icon is custom artwork from ThaPHLASH


OP JBirdVegas

JBirdVegas

java code monkey

Posted 08 October 2011 - 10:41 PM #2

updated to include an example of an IconPreferenceScreen

that launches a link to the source code repo hosted on github

here is how i did it
https://github.com/n...496ce5643886749

enjoy

Attached Files


Edited by JBirdVegas, 10 October 2011 - 12:06 PM.

  • 0 Likes

Show Your appreciation by clicking Thanks!

I co-maintain the droid2 branch of CyanogenMod, n00bware founder and lead developer and a developer for AOKP
my icon is custom artwork from ThaPHLASH


OP JBirdVegas

JBirdVegas

java code monkey

Posted 10 October 2011 - 12:10 PM #3

Updated to include handling of HardKey menu press

here is how:
https://github.com/n...3d7244a2591dda2

Attached Files


  • 0 Likes

Show Your appreciation by clicking Thanks!

I co-maintain the droid2 branch of CyanogenMod, n00bware founder and lead developer and a developer for AOKP
my icon is custom artwork from ThaPHLASH


BMc08GT

BMc08GT

Android Guru

Posted 03 March 2012 - 07:14 PM #4

awesome JBird this will come in handy. Thanks
  • 0 Likes
--TeamKang Member--

Appreciate what I do or like my work? Buy me a shot and I love you long time. <3

OP JBirdVegas

JBirdVegas

java code monkey

Posted 03 March 2012 - 08:19 PM #5

awesome JBird this will come in handy. Thanks

It be happy to further explain any concepts if needed. You can do lots of fun stuff from here.
  • 0 Likes

Show Your appreciation by clicking Thanks!

I co-maintain the droid2 branch of CyanogenMod, n00bware founder and lead developer and a developer for AOKP
my icon is custom artwork from ThaPHLASH