2012-11-05 83 views
0

過去幾個小時我一直在瘋狂。不能得到這個工作: 我有一個偏好,佈局和活動。但我不能在佈局中得到優先... 偏好:佈局內的首選項屏幕

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > 
    <CheckBoxPreference 
     android:key="show_numbers" 
     android:title="show tile numbers" 
     android:summary="display the correct location of the tiles" 
     android:defaultValue="false" /> 
    <ListPreference 
     android:key="grid_size" 
     android:title="Grid Size" 
     android:summary="puzzle size" 
     android:entries="@array/gridSizeTitles" 
     android:entryValues="@array/gridSizeValues" 
     android:defaultValue="3" /> 
</PreferenceScreen> 

佈局:

 <RelativeLayout xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/mainbgcolor" xmlns:android="http://schemas.android.com/apk/res/android"> 

    <RelativeLayout 
     android:id="@+id/relativeLayoutHeader" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <TextView 
      android:id="@+id/txtvHeader" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:padding="20dip" 
      android:text="Sliding Puzzle" 
      android:textColor="#242FF0" 
      android:textSize="20dip" 
      android:textStyle="bold|normal" /> 

     <ImageView 
      android:id="@+id/ivHeader" 
      android:layout_width="50dip" 
      android:layout_height="50dip" 
      android:layout_centerVertical="true" 
      android:layout_toLeftOf="@+id/txtvHeader" 
      android:contentDescription="Sliding Puzzle Icon" 
      android:scaleType="fitCenter" 
      android:src="@drawable/slidingpuzzleicon" /> 
    </RelativeLayout> 


<LinearLayout 
     android:id="@+id/LinearLayoutContent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_below="@+id/relativeLayoutHeader" 
     android:orientation="vertical" > 

<!-- THIS IS THE PLACE I WANT TO GET THE PREFERENCE. 
    I ALSO WANT BE ABLE TO POSITION THE PREFERENCE VIEWS. --> 

    </LinearLayout> 

</RelativeLayout> 

任何幫助將受到歡迎。

在此先感謝,olijf

+1

我不認爲你可以做到這一點。可能有一個首選項屏幕,您可以獲取頂視圖並在那裏注入您的佈局,但我甚至不確定。 – njzk2

回答

2
<!-- THIS IS THE PLACE I WANT TO GET THE PREFERENCE. 
    I ALSO WANT BE ABLE TO POSITION THE PREFERENCE VIEWS. --> 

然後,你將需要繪製自己的UI爲,而不是使用PreferenceScreen

PreferenceScreen系統背後的觀點是提供一種收集偏好的標準化方式,以便用戶知道該期待什麼以及UI的工作原理。你想要的是實現收集偏好的非標準化方式。歡迎您這樣做,但您需要爲此推出自己的用戶界面。