Need help with SettingView?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

chentao0707
208 Stars 91 Forks Apache License 2.0 8 Commits 1 Opened issues

Description

类似主流应用的设置视图

Services available

!
?

Need anything else?

Contributors list

# 18,986
Java
D
Shell
6 commits
# 451,275
Java
1 commit

Logo SettingView

SettingView是类似主流应用的设置界面用到的控件,主要思路来源于iPhone的设置界面

Examples Screenshots

screenshots01 screenshots02 screenshots03 screenshots04

Features

  • 支持XML手动布局,XML属性设置

  • 支持动态添加

  • 数据源适配通过类似setAdapter方法提供

  • 当然你还可以扩展更多...

Usage

1.下载SettingViewLibrary导入Eclipse作为项目库

2.在布局中添加自定义属性并引用SettingView

<com.dtr.settingview.lib.settingview android:id="@+id/main_setting_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="20dp" app:iosstyle="false"></com.dtr.settingview.lib.settingview>

3.Activity中设置数据源

private void initView() {
        mItemViewData = new SettingViewItemData();
        mItemData = new SettingData();
        mItemData.setTitle("仿QQ界面效果");

    mItemViewData.setData(mItemData);
    mItemViewData.setItemView(new BasicItemViewH(MainActivity.this));
    mListData.add(mItemViewData);

    mItemViewData = new SettingViewItemData();
    mItemData = new SettingData();
    mItemData.setTitle("仿iOS设置界面");

    mItemViewData.setData(mItemData);
    mItemViewData.setItemView(new BasicItemViewH(MainActivity.this));
    mListData.add(mItemViewData);

    mItemViewData = new SettingViewItemData();
    mItemData = new SettingData();
    mItemData.setTitle("单个Item布局效果");

    mItemViewData.setData(mItemData);
    mItemViewData.setItemView(new BasicItemViewH(MainActivity.this));
    mListData.add(mItemViewData);

    mSettingView.setAdapter(mListData);
}

4.设置事件监听

mSettingView.setOnSettingViewItemClickListener(new onSettingViewItemClickListener() {

        @Override
        public void onItemClick(int index) {
            // TODO Auto-generated method stub
            switch (index) {
            case 0:
                startActivity(new Intent(MainActivity.this, QQStyleActivity.class));
                break;
            case 1:
                startActivity(new Intent(MainActivity.this, IosStyleActivity.class));

                break;
            case 2:
                startActivity(new Intent(MainActivity.this, XMLLayoutActivity.class));

                break;

            default:
                break;
            }
        }
    });

5.属性解释

  • iOSStyle:是否使用类似iPhone中的设置界面效果,也就是分割线的样式

  • title:标题文字

  • subTitle:副标题文字

  • titleColor:标题文字颜色

  • subTitleColor:副标题文字颜色

  • titleSize:标题文字大小

  • subTitleSize:副标题文字大小

  • drawable:控件ItemView的Icon资源

  • arrow:箭头的资源文件

  • check:当控件类型是选择框时的标记图片资源

  • image:当控件的副标题是图片类型时的默认图片资源

  • clickable:控件初始时是否可以点击,大部分都是可以点击的,只是开关控件会不同

  • checked:控件初始时是否是选中状态,作用于开关选项和单选选项

  • background:控件整体的背景资源

6.回调方法:

// Item控件被点击时的监听方法,index即为操作时的下标
public interface onSettingViewItemClickListener {
    void onItemClick(int index);
}

// Item控件中为开关时的监听方法,index即为操作时的下标,isChecked即为是否选中 public interface onSettingViewItemSwitchListener { public void onSwitchChanged(int index, boolean isChecked); }

7.更多使用请参考SettingViewExamples示例程序

License

/*
 * Copyright (C) 2014 Chen Tao <[email protected]>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.