2012-01-19 16 views
10

私はPreferenceScreenを作成しようとしていますが、私はプロジェクト全体のようなアクティビティデザインが必要です。Android:どのようにカスタムPreferenceScreenを作成できますか?

どのようにカスタムPreferenceScreenデザインを作成できますか?

+0

申し訳ありませんが、あなたの質問を拡大できますか?それとももっときれいにするか?私はあなたのことがデザイン/グラフィックの問題だと思っています – StErMi

+0

ああ、しかし、私はそのdoableを尋ねたい。 – Basbous

答えて

2

これはあなたが探しているものだと思います。

PreferenceScreen screen = createPreferenceHierarchy(); 

...
this.setContentView(rootView); =>私はあなたにも、XMLレイアウトから、それを設定することができると思います。

setPreferenceScreen(screen); 
+0

リンクが壊れています:( – philipp

12

はい、実行できます。レイアウトのための謝罪、私の貼り付けは、右の書式設定を維持すると思われることはありませんが、コンテンツの動作...

Preferences.java

import android.content.Intent; 
    import android.os.Bundle; 
    import android.preference.PreferenceActivity; 
    import android.view.View; 
    import android.widget.Button; 

    public class Preferences extends PreferenceActivity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.preference_holder); 
    addPreferencesFromResource(R.layout.preferences); 

    Button backButton = (Button) findViewById(R.id.backPrefBurron); 
    backButton.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View view) { 
      Intent myIntent = new Intent(getBaseContext(), 
        BTFirstTab.class); 
      startActivity(myIntent); 
     } 
    }); 

    } 
    } 

その後、好みが好みそして

<?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"> 
<LinearLayout android:orientation="horizontal" 
    android:background="@color/bto_dark_green" android:layout_width="fill_parent" 
    android:gravity="center_vertical" android:layout_height="wrap_content" 
    android:paddingTop="4dip"> 
    <Button android:id="@+id/backPrefBurron" android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:text="Home" /> 

    <TextView android:id="@+id/backText" android:textSize="14dip" 
     android:paddingLeft="5dip" android:textColor="@color/white" 
     android:textStyle="bold" android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:layout_weight="1.0" 
     android:text="Preferences: Home will update all areas of the app" /> 
</LinearLayout> 
<ListView android:id="@android:id/list" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 
</LinearLayout> 

をholder.xml .xml

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" 
    android:background="@color/bto_light_green"> 

<EditTextPreference android:title="Your BTO UserName" 
    android:key="username" android:summary="Please provide your username">   </EditTextPreference> 
<EditTextPreference android:title="Your BTO Password" 
    android:password="true" android:key="password" android:summary="Please provide your password (case sensitive)"></EditTextPreference> 
<ListPreference android:title="Species order" 
    android:summary="This preference selects the species order for some viewing sightings activities" 
    android:key="speciesorder" android:defaultValue="date_order" android:entries="@array/listArray" 
    android:entryValues="@array/listValues"></ListPreference> 
    </PreferenceScreen> 

このように、私は他のページで使用する共通のヘッダーを持っています。

+0

私はpreferenceFragmentを使用していますか? – Michal

関連する問題