您的位置:首页 > Web前端

PreferenceFragment 使用-> 自定义preferences的布局

2016-04-20 15:28 417 查看

PreferenceFragment 使用-> 自定义preferences的布局

1.***Fragment 继承 PreferenceFragment

2.重写

public View onCreateView(LayoutInflater inflater, ViewGroup container,

            Bundle savedInstanceState) 方法(不需要调用父类方法)

3.inflater.inflate(R.layout.****_screen, container, false);

 其中****_screen需要包含:    

<ListView

        android:id="@android:id/list"             

        android:layout_width="match_parent"

        android:layout_height="0dip"

        android:layout_weight="1"

        android:clipToPadding="false"

        android:scrollbarStyle="outsideOverlay" />

 

注: id必须为"@android:id/list"             

此ListView放preferenceScreen的地方

4.可以修改listview的padding

5.在xml下写一个PreferenceScreen的布局

6.调用addPreferencesFromResource(R.xml.***)

   Preference布局在ListView中

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息