{"id":257,"date":"2010-10-03T23:03:48","date_gmt":"2010-10-03T14:03:48","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2010\/10\/03\/android_android_hacks\/"},"modified":"2010-10-03T23:03:48","modified_gmt":"2010-10-03T14:03:48","slug":"android_android_hacks","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2010\/10\/03\/android_android_hacks\/","title":{"rendered":"Android \u8a2d\u5b9a\u753b\u9762\u3092\u7c21\u5358\u306b\u4f5c\u6210\u3059\u308b (ANDROID HACKS)"},"content":{"rendered":"<p><iframe style=\"width: 120px; height: 240px\" marginheight=\"0\" src=\"http:\/\/rcm-jp.amazon.co.jp\/e\/cm?lt1=_blank&amp;bc1=FFFFFF&amp;IS2=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=typea09-22&amp;o=9&amp;p=8&amp;l=as1&amp;m=amazon&amp;f=ifr&amp;md=1X69VDGQCMF7Z30FM082&amp;asins=487311456X\" frameborder=\"0\" marginwidth=\"0\" scrolling=\"no\"><\/iframe>  <\/p>\n<p>&nbsp;<\/p>\n<p>\u4eca\u306e\u3068\u3053\u308d\u3001\u81ea\u5206\u306fAndroid\u884c\u304d\u8a70\u307e\u3063\u305f\u3089\u3001<a href=\"http:\/\/goosh.org\/\">http:\/\/goosh.org\/<\/a> \u3067\u3001how to use surfaceview? \u306a\u3069\u3068\u6253\u3061\u8fbc\u3093\u3067\u3001<a href=\"http:\/\/stackoverflow.com\/questions\/tagged\/android\">stackoverflow<\/a> \u306e\u6295\u7a3f\u306b\u884c\u304d\u5f53\u305f\u308a\u3001\u305d\u308c\u3067\u89e3\u6c7a\u3059\u308b\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u3059\u304c\u3001\u672c\u66f8\u306b\u4e00\u901a\u308a\u3001\u3056\u3063\u3068\u76ee\u3092\u901a\u3057\u305f\u3068\u3053\u308d\u3001 HACKS \u306e\u540d\u306e\u901a\u308a\u3001\u300c\u3042\u306e\u6a5f\u80fd\u306f\u3069\u3046\u3084\u3063\u3066\u5b9f\u73fe\u3059\u308b\u306e\u3060\u308d\u3046\uff1f\u300d\u3068\u6c17\u306b\u306a\u3063\u305f\u3068\u304d\u306b\u5f79\u306b\u7acb\u3061\u305d\u3046\u306aTIPS\u304c\u6e80\u8f09\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3055\u3063\u305d\u304f\u3001\u300cHACK #113 \u8a2d\u5b9a\u753b\u9762\u3092\u7c21\u5358\u306b\u4f5c\u6210\u3059\u308b\u300d \u306e\u529b\u3092\u501f\u308a\u308b\u65e5\u304c\u3084\u3063\u3066\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u308c\u3092\u307f\u3066\u3061\u3083\u3063\u3061\u3083\u3068\u8a2d\u5b9a\u753b\u9762\u3092\u5b9f\u88c5\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Android_10759\/android_preferences01.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"android_preferences01\" border=\"0\" alt=\"android_preferences01\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Android_10759\/android_preferences01_thumb.jpg\" width=\"183\" height=\"303\" \/><\/a> <\/p>\n<p>\u4e0a\u8a18\u306e\u69d8\u306a\u753b\u9762\u3092\u7c21\u5358\u306b\u4f5c\u6210\u3067\u304d\u308b\u306f\u305a\u3002<\/p>\n<p>\u30fb\u30fb\u30fb \u3060\u3063\u305f\u3093\u3067\u3059\u304c\u3001<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Android_10759\/android_preferences02.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"android_preferences02\" border=\"0\" alt=\"android_preferences02\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Android_10759\/android_preferences02_thumb.jpg\" width=\"313\" height=\"268\" \/><\/a> <\/p>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b<a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/Preference.html\">\u8a2d\u5b9a\u7528\u306eUI\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306f\u3001\u4ee5\u4e0b\u3050\u3089\u3044<\/a>\u3089\u3057\u304f\u3001\u4e0a\u8a18\u4f8b\u306e\u3088\u3046\u306a\u3001<a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/SeekBar.html\">SeekBar<\/a> \u3092\u5229\u7528\u3059\u308b\u8a2d\u5b9a\u753b\u9762\u306f\u3001\u305d\u3053\u307e\u3067\u7c21\u5358\u306b\u306f\u4f5c\u6210\u3067\u304d\u306a\u3044\u3088\u3046\u3067\u3002\u3002\u3002\u3067\u304d\u3066\u3082\u826f\u3055\u305d\u3046\u306a\u306e\u306b\u3002\u3002\u3002<\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"400\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"200\">UI\u90e8\u54c1<\/td>\n<td valign=\"top\" width=\"200\">\u5185\u5bb9<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"200\">CheckBoxPreference<\/td>\n<td valign=\"top\" width=\"200\">\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"200\">EditTextPreference<\/td>\n<td valign=\"top\" width=\"200\">\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"200\">ListPreference<\/td>\n<td valign=\"top\" width=\"200\">\u30e9\u30b8\u30aa\u30dc\u30bf\u30f3\u306e\u30ea\u30b9\u30c8<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"200\">\n<p>RingtonePreference<\/p>\n<\/td>\n<td valign=\"top\" width=\"200\">\u7740\u4fe1\u97f3\u30ea\u30b9\u30c8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>\u3082\u3046\u5c11\u3057\u6642\u9593\u3092\u304b\u3051\u3066\u8003\u3048\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u7d50\u679c\u3001\u4ee5\u4e0b\u306e\u69d8\u306b\u3001\u5b9f\u88c5\u3057\u3001\u307b\u307c\u307b\u307c\u52d5\u3044\u3066\u3044\u308b\u306e\u3067\u3001\u624b\u9806\u3092\u30e1\u30e2\u3057\u307e\u3059\u3002<\/p>\n<p>\u57fa\u672c\u7684\u306b\u306f\u3001<\/p>\n<ol>\n<li>Preference \u30af\u30e9\u30b9\u306e\u4f5c\u6210<\/li>\n<li>Preference \u30af\u30e9\u30b9\u7528\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u306e\u4f5c\u6210<\/li>\n<li>PreferenceActivity \u7528 \u30ec\u30a4\u30a2\u30a6\u30c8\u306e\u4f5c\u6210<\/li>\n<li>PreferenceActivity \u306e\u4f5c\u6210<\/li>\n<\/ol>\n<p>\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>SeekBarPreference \u30af\u30e9\u30b9\u306e\u4f5c\u6210<\/h2>\n<p>\u307e\u305a\u3001\u8a2d\u5b9a\u753b\u9762\u7528\u306eActivity \u3067\u3042\u308b\u3001<a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/PreferenceActivity.html\">PreferenceActivity<\/a> \u306b\u3066\u4f7f\u7528\u3059\u308b\u3001UI\u90e8\u54c1\u3067\u3042\u308b\u3001<a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/Preference.html\">Preference<\/a> \u30af\u30e9\u30b9\u3092\u7d99\u627f\u3057\u3066\u3001SeekBar \u3092\u4f7f\u3063\u305f\u8a2d\u5b9a\u7528\u90e8\u54c1\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u30ec\u30a4\u30a2\u30a6\u30c8\u306f\u3001\u5f8c\u3067\u8a18\u8ff0\u3057\u307e\u3059\u304c\u3001\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3067 XML(\/res\/layout\/preference_widget_seekbar.xml) \u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<\/p>\n<p>Log \u3092\u51fa\u529b\u3057\u305f\u3068\u3053\u308d\u3001\u4ee5\u4e0b\u306e\u9806\u3067\u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3070\u308c\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<ol>\n<li>onGetDefaultValue&nbsp; \u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u8aad\u307f\u8fbc\u307f <\/li>\n<li>onSetInitialValue \u521d\u671f\u5024\u3092\u8a2d\u5b9a <\/li>\n<li>onBindView \u30d3\u30e5\u30fc\u3068\u30c7\u30fc\u30bf\u3092\u30d0\u30a4\u30f3\u30c9 <\/li>\n<\/ol>\n<pre class=\"prettyprint linenums\"> package info.typea.shujiroid.core;\r\n \r\n import info.typea.shujiroid.free.R;\r\n import android.content.Context;\r\n import android.content.res.TypedArray;\r\n import android.preference.Preference;\r\n import android.util.AttributeSet;\r\n import android.view.View;\r\n import android.widget.SeekBar;\r\n import android.widget.SeekBar.OnSeekBarChangeListener;\r\n \r\n \/**\r\n  * @author piroto\r\n  *\/\r\n public class SeekBarPreference extends Preference implements OnSeekBarChangeListener {\r\n \r\n     private static final int MAX_PROGRESS = 100;\r\n     private static final int DEFAULT_PROGRESS = 50; \r\n     private int currentProgress;\r\n     private int oldProgress;\r\n     \r\n     public SeekBarPreference(Context context, AttributeSet attrs) {\r\n         super(context, attrs);\r\n         setWidgetLayoutResource(R.layout.preference_widget_seekbar);\r\n     }\r\n     \r\n     \/* \r\n      * Preference \u304c \u547c\u3073\u51fa\u3055\u308c\u308b\u3068\u304d\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u304c\u8aad\u307f\u8fbc\u307e\u308c\u308b\u5fc5\u8981\u304c\u3042\u308b\r\n      * \u7570\u306a\u308b Preference \u578b\u306f\u7570\u306a\u308b \u5024\u578b \u306f\u6301\u3064\u306f\u305a\u306a\u306e\u3067\u3001\u30b5\u30d6\u30af\u30e9\u30b9\u306f\u305d\u308c\u306b\u3042\u308f\u305b\u305f\u578b\u3092\u8fd4\u3059\u5fc5\u8981\u304c\u3042\u308b\r\n      *\/\r\n     @Override\r\n     protected Object onGetDefaultValue(TypedArray a, int index) {\r\n         return a.getInteger(index, DEFAULT_PROGRESS);\r\n     }\r\n \r\n     \/* \r\n      * Preference \u306e\u521d\u671f\u5024\u3092\u8a2d\u5b9a\u3059\u308b\r\n      * restorePersistedValue \u304c true \u306e\u5834\u5408\u3001Preference \u5024\u3092\u3001SharedPreference \u304b\u3089\u30ec\u30b9\u30c8\u30a2\u3059\u3079\u304d\r\n      * false \u306e\u5834\u5408 Preference \u5024\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u30bb\u30c3\u30c8\r\n      * (SharedPreference \u306e\u3000shouldPersist() \u304c true \u306e\u5834\u5408\u3001\u53ef\u80fd\u306a\u3089SharedPreference\u306b\u5024\u3092\u683c\u7d0d) \r\n      *\/\r\n     @Override\r\n     protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue) {\r\n         if (restorePersistedValue) {\r\n             currentProgress = getPersistedInt(currentProgress);\r\n         } else {\r\n             currentProgress = (Integer) defaultValue;\r\n             persistInt(currentProgress);\r\n         }\r\n         oldProgress = currentProgress;\r\n     }\r\n \r\n     \/*\r\n      * Preference \u306e\u305f\u3081\u306b\u3001\u30d3\u30e5\u30fc\u3068\u30c7\u30fc\u30bf\u3092\u30d0\u30a4\u30f3\u30c9\u3059\u308b\r\n      * \u30ec\u30a4\u30a2\u30a6\u30c8\u304b\u3089\u30ab\u30b9\u30bf\u30e0\u30d3\u30e5\u30fc\u3092\u53c2\u7167\u3057\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8a2d\u5b9a\u3059\u308b\u306e\u306b\u9069\u3059\u308b\r\n      * \u30b9\u30fc\u30d1\u30fc\u30af\u30e9\u30b9\u306e\u5b9f\u88c5\u306e\u547c\u3073\u51fa\u3057\u3092\u78ba\u5b9f\u306b\u884c\u3046\u3053\u3068\r\n      *\/\r\n     @Override\r\n     protected void onBindView(View view) {\r\n         final SeekBar seekbar = (SeekBar) view.findViewById(R.id.pref_seekbar);\r\n         if (seekbar != null) {\r\n             seekbar.setProgress(currentProgress);\r\n             seekbar.setMax(MAX_PROGRESS);\r\n             seekbar.setOnSeekBarChangeListener(this);\r\n         }\r\n         super.onBindView(view);\r\n     }\r\n \r\n     @Override\r\n     public void onStartTrackingTouch(SeekBar seekbar) {}\r\n     @Override\r\n     public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) {}\r\n     \r\n     @Override\r\n     public void onStopTrackingTouch(SeekBar seekbar) {\r\n         int progress = seekbar.getProgress();\r\n         \/* \u30e6\u30fc\u30b6\u30fc\u304c\u8a2d\u5b9a\u5909\u66f4\u3092\u884c\u3063\u305f\u5f8c(\u5185\u90e8\u7684\u306a\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u524d)\u306b\u547c\u3073\u51fa\u3059\u3002 *\/\r\n         currentProgress = (callChangeListener(progress))?progress:oldProgress;\r\n \r\n         persistInt(currentProgress);\r\n         oldProgress = currentProgress;\r\n     }\r\n }<\/pre>\n<h2>SeekBarPreference UI \u90e8\u54c1\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u5b9a\u7fa9(\/res\/layout\/preference_widget_seekbar.xml)<\/h2>\n<p>\u4eca\u56de SeekBar \u306e\u307f\u3067\u69cb\u6210\u3057\u307e\u3057\u305f\u304c\u3001\u901a\u5e38\u306e\u753b\u9762\u3092\u4f5c\u308b\u3088\u3046\u306b\u8907\u6570\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3082\u51fa\u6765\u305d\u3046\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint linenums\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\" \r\n    android:id=\"@+id\/LinearLayout01\" \r\n    android:layout_width=\"fill_parent\" \r\n    android:layout_height=\"fill_parent\" &gt;\r\n    &lt;SeekBar android:id=\"@+id\/pref_seekbar\" \r\n             android:layout_width=\"wrap_content\" \r\n             android:layout_height=\"wrap_content\"\r\n             xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\" android:minWidth=\"100sp\"&gt;\r\n    &lt;\/SeekBar&gt;\r\n&lt;\/LinearLayout&gt;<\/pre>\n<p>&nbsp;<\/p>\n<h2>PreferenceActivity \u306e\u30ec\u30a4\u30a2\u30a6\u30c8&amp;\u5b9a\u7fa9(\/res\/xml\/preferences.xml) \u3092\u4f5c\u6210<\/h2>\n<p>\u8a2d\u5b9a\u753b\u9762\u306e\u30ec\u30a4\u30a2\u30a6\u30c8 XML \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u901a\u5e38\u306e\u753b\u9762\u30ec\u30a4\u30a2\u30a6\u30c8\u3068\u306f\u3001\u7f6e\u304d\u5834\u6240\u3084\u66f8\u304d\u65b9\u304c\u7570\u306a\u308a\u307e\u3059\u3002\u3053\u306e\u3042\u305f\u308a\u306e\u8a73\u7d30\u306f\u3001\u4e0a\u8a18 <a href=\"http:\/\/www.amazon.co.jp\/gp\/product\/487311456X?ie=UTF8&amp;tag=typea09-22&amp;linkCode=as2&amp;camp=247&amp;creative=7399&amp;creativeASIN=487311456X\">Android Hacks \u2015\u30d7\u30ed\u304c\u6559\u3048\u308b\u30c6\u30af\u30cb\u30c3\u30af &amp; \u30c4\u30fc\u30eb<\/a><img loading=\"lazy\" decoding=\"async\" style=\"border-bottom-style: none !important; border-right-style: none !important; margin: 0px; border-top-style: none !important; border-left-style: none !important\" border=\"0\" alt=\"\" src=\"http:\/\/www.assoc-amazon.jp\/e\/ir?t=typea09-22&amp;l=as2&amp;o=9&amp;a=487311456X\" width=\"1\" height=\"1\" \/> \u3092\u78ba\u8a8d\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u4ee5\u4e0b\u306f\u3001\u4e0a\u8a18\u4f8b\u306e\u8a2d\u5b9a\u7528XML\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>android:key \u306e\u5024\u306b\u3066\u3001<a href=\"http:\/\/developer.android.com\/reference\/android\/content\/SharedPreferences.html\">SharedPreference<\/a> \u304b\u3089 \u8a2d\u5b9a\u5024\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u69d8\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u554f\u984c\u306e\u3001SeekBarPreference \u306e\u5229\u7528\u6cd5\u306f\u3001info.typea.shujiroid.core.SeekBarPreference \u8981\u7d20\u3092\u53c2\u7167\u3002<\/p>\n<pre class=\"prettyprint linenums\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;PreferenceScreen\r\n        xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"&gt;\r\n    &lt;PreferenceCategory\r\n            android:title=\"@string\/lbl_brush_pref_title\"&gt;\r\n        &lt;info.typea.shujiroid.core.SeekBarPreference\r\n                android:key=\"calligraphy_diameter\"\r\n                android:title=\"@string\/lbl_diameter_of_brush\"\r\n                android:summary=\"@string\/lbl_diameter_of_brush_summary\"\r\n                android:defaultValue=\"50\"\/&gt;\r\n\r\n        &lt;info.typea.shujiroid.core.SeekBarPreference\r\n                android:key=\"calligraphy_smoothness\"\r\n                android:title=\"@string\/lbl_smoothness_of_brush\"\r\n                android:summary=\"@string\/lbl_smoothness_of_brush_summary\"\r\n                android:defaultValue=\"50\"\/&gt;\r\n\r\n        &lt;info.typea.shujiroid.core.SeekBarPreference\r\n                android:key=\"calligraphy_alpha\"\r\n                android:title=\"@string\/lbl_alpha_of_brush\"\r\n                android:summary=\"@string\/lbl_alpha_of_brush_summary\"\r\n                android:defaultValue=\"50\"\/&gt;\r\n\r\n        &lt;CheckBoxPreference\r\n                android:key=\"calligraphy_antialias\"\r\n                android:title=\"@string\/lbl_antialias\"\r\n                android:summary=\"@string\/lbl_antialias_summary\" \/&gt;\r\n        &lt;ListPreference \r\n                android:key=\"calligraphy_color\"\r\n                android:title=\"@string\/lbl_brush_color\"\r\n                android:summary=\"@string\/lbl_brush_color_summary\"\r\n                android:entries=\"@array\/ary_colors\" \r\n                android:entryValues=\"@array\/ary_color_values\" \/&gt;\r\n        &lt;ListPreference \r\n                android:key=\"calligraphy_background_color\"\r\n                android:title=\"@string\/lbl_background_color\"\r\n                android:summary=\"@string\/lbl_background_color_summary\"\r\n                android:entries=\"@array\/ary_colors\" \r\n                android:entryValues=\"@array\/ary_color_values\" \/&gt;\r\n        &lt;CheckBoxPreference\r\n                android:key=\"shujiview_vibrate\"\r\n                android:title=\"@string\/lbl_vibrate\"\r\n                android:summary=\"@string\/lbl_vibrate_summary\" \/&gt;\r\n   &lt;\/PreferenceCategory&gt;\r\n&lt;\/PreferenceScreen&gt;<\/pre>\n<h2>\u8a2d\u5b9a\u753b\u9762(PreferenceActivity) \u306e\u4f5c\u6210<\/h2>\n<p>res\/xml\/preferences.xml \u3067\u5b9a\u7fa9\u3057\u305f\u3001Preference (\u8a2d\u5b9a\u9805\u76ee\u306eUI\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8) \u304b\u3089\u5024\u3092\u8a2d\u5b9a\u3001\u53d6\u5f97\u3059\u308b\u305f\u3081\u306e\u30ad\u30fc\u3092\u3001\u8a2d\u5b9a\u753b\u9762\u547c\u3073\u51fa\u3057\u5143\u306eActivity \u304b\u3089\u53c2\u7167\u3067\u304d\u308b\u69d8\u306b\u5b9a\u6570\u5316\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u305d\u308c\u4ee5\u5916\u306f\u4f55\u3082\u3057\u3066\u307e\u305b\u3093\u3002PreferenceActivity \u3092\u7d99\u627f\u3057\u3066\u81ea\u5206\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u7528\u306e Activity \u3092\u4f5c\u6210\u3057\u3001addPreferencesFromResource \u3092\u5229\u7528\u3057\u3066\u3001\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u53c2\u7167\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint linenums\">package info.typea.shujiroid.core;\r\n\r\nimport info.typea.shujiroid.free.R;\r\nimport android.os.Bundle;\r\nimport android.preference.PreferenceActivity;\r\n\r\npublic class ShujiPreferenceActivity extends PreferenceActivity {\r\n    public static final String KEY_CALLIGRAPYHY_DIAMETER         = \"calligraphy_diameter\";\r\n    public static final String KEY_CALLIGRAPYHY_SMOOTH           = \"calligraphy_smoothness\";\r\n    public static final String KEY_CALLIGRAPYHY_ALPAH            = \"calligraphy_alpha\";\r\n    public static final String KEY_CALLIGRAPYHY_ANTIALIAS        = \"calligraphy_antialias\";\r\n    public static final String KEY_CALLIGRAPYHY_COLOR            = \"calligraphy_color\";\r\n    public static final String KEY_CALLIGRAPYHY_BACKGROUNDCOLOR  = \"calligraphy_background_color\";\r\n    public static final String KEY_SHUJIVIEW_VIBRATE             = \"shujiview_vibrate\";\r\n    \r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        addPreferencesFromResource(R.xml.preferences);\r\n    }\r\n}<\/pre>\n<h2>\u8a2d\u5b9a\u3092\u5229\u7528\u3059\u308b<\/h2>\n<p>\u3053\u308c\u3067\u3001\u8a2d\u5b9a\u753b\u9762\u304c\u5b8c\u6210\u3057\u307e\u3057\u305f\u3002\u30e1\u30a4\u30f3\u306e\u30a2\u30af\u30c6\u30a3\u30d3\u30c6\u30a3\u304b\u3089\u5229\u7528\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<h3>\u8a2d\u5b9a\u753b\u9762\u3092\u547c\u3073\u51fa\u3059<\/h3>\n<p>\u4efb\u610f\u306e\u5024(\u3053\u3053\u3067\u306f\u3001REQUEST_CODE_PREFERENCS \u3068\u3057\u307e\u3057\u305f)\u3092\u6307\u5b9a\u3057\u3066\u3001startActivityForResult \u3092\u547c\u3073\u51fa\u3059\u3002 <\/p>\n<pre class=\"prettyprint linenums\">private static final int REQUEST_CODE_PREFERENCES = 1;\r\n   :\r\nstartActivityForResult(new Intent(this, ShujiPreferenceActivity.class),REQUEST_CODE_PREFERENCES);<\/pre>\n<h3>\u8a2d\u5b9a\u753b\u9762\u3092\u9589\u3058\u308b<\/h3>\n<p>\u8a2d\u5b9a\u753b\u9762\u3092\u9589\u3058\u308b\u3068\u3001onActivityResult \u304c\u547c\u3070\u308c\u308b\u306e\u3067\u3001\u3053\u308c\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3057\u307e\u3059\u3002<\/p>\n<p>\u5148\u307b\u3069\u8a2d\u5b9a\u3057\u305f\u4efb\u610f\u306e\u30b3\u30fc\u30c9\u304c\u5426\u304b\u3092 requestCode \u3067\u5224\u5b9a\u3057\u3066\u3001\u540c\u4e00\u306a\u3089\u3001SharedPrerferences \u304b\u3089\u3001\u8a2d\u5b9a\u5024\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint linenums\">@Override\r\nprotected void onActivityResult(int requestCode, int resultCode, Intent data) {\r\n    super.onActivityResult(requestCode, resultCode, data);\r\n    if (requestCode == REQUEST_CODE_PREFERENCES) {\r\n\r\n        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);\r\n        \r\n        int diameter = pref.getInt(ShujiPreferenceActivity.KEY_CALLIGRAPYHY_DIAMETER, 50);\r\n        int smooth   = pref.getInt(ShujiPreferenceActivity.KEY_CALLIGRAPYHY_SMOOTH, 50);\r\n                          :\r\n    }\r\n}<\/pre>\n<p>\u4ee5\u4e0a\u306e\u624b\u9806\u3067\u3001\u30ab\u30b9\u30bf\u30e0Preference \u3092\u5229\u7528\u3057\u305f\u8a2d\u5b9a\u753b\u9762\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p>\u6700\u5f8c\u306e\u8a70\u3081\u3092\u8003\u3048\u3055\u305b\u308b\u4f5c\u308a\u306b\u306a\u3063\u3066\u3044\u308b\u3042\u305f\u308a\u3001\u3055\u3059\u304c ANDROID HACKS \u3068\u3044\u3046\u6c17\u3082\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u4e00\u6b69\u91ce\u671b\u306b\u8fd1\u3065\u3044\u305f\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u4eca\u306e\u3068\u3053\u308d\u3001\u81ea\u5206\u306fAndroid\u884c\u304d\u8a70\u307e\u3063\u305f\u3089\u3001http:\/\/goosh.org\/ \u3067\u3001how to use surfaceview? \u306a\u3069\u3068\u6253\u3061\u8fbc\u3093\u3067\u3001stackoverflow \u306e\u6295\u7a3f\u306b\u884c\u304d\u5f53\u305f\u308a\u3001\u305d\u308c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[39],"tags":[],"class_list":["post-257","post","type-post","status-publish","format-standard","hentry","category-android"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=257"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/257\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}