PreferenceActivityã®ã¬ã¤ã¢ã¦ãã«ã¹ã¿ãã¤ãº
ãã¢ã«ã¦ã³ãã¨åæã®è¨å®ãã¿ãããªç»é¢ãã¤ãã
ãã¢ã«ã¦ã³ãã¨åæã®è¨å®ãç»é¢ã¿ãããªç»é¢ãã¤ããã«ã¯ã©ãããã°ããã§ãããã
åºæ¬ã¯PreferenceActivityã ãã©ãããã¿ã¼é¨åã®ãã¿ã³ã追å ããã«ã¯å·¥å¤«ãå¿
è¦ããã§ãã
èªä½layoutã«preferenceãè¼ããæ¹æ³
PreferenceActivityã®ã¬ã¤ã¢ã¦ãå¤æ´ - ãã¯ã¡ã¢
ä¸è¨ãã¼ã¸ã«ãèªä½layoutã«preferenceãè¼ããæ¹æ³ãç´¹ä»ããã¦ãã¾ããã
@android:id/listãªListViewãæã¤layoutãsetContentViewããã¨ãpreferenceãè¼ãListViewãå·®ãæ¿ããããããã§ããListViewã«layout_weightãæå®ãã¦ãããªãã¨Buttonã表示ããã¾ããã§ããã
SamplePreferenceActivity
public class SamplePrerenceActivity extends PreferenceActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.linear); addPreferencesFromResource(R.xml.pref); } }
linear.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" /> <LinearLayout android:layout_width="match_parent" android:background="#aaaaaa" android:gravity="center_horizontal" android:paddingTop="10dip" android:layout_height="wrap_content"> <Button android:layout_width="wrap_content" android:text="ã¢ã«ã¦ã³ãã追å " android:layout_height="wrap_content" /> </LinearLayout> </LinearLayout>
å®éã®è¡¨ç¤º
ä¸è¨ã³ã¼ãã¨pref.xmlã«ãããä¼¼ããããªã¬ã¤ã¢ã¦ããå®ç¾ã§ãã¾ããã