Skip to content

多选代理是用于Android开发中的列表项多选处理的解耦工具,提供零介入实现多选、单选、普通列表界面切换的功能,包括选择结果集的提取

License

Notifications You must be signed in to change notification settings

AIYKUN/MultipleChoiceProxy

Repository files navigation

MultipleChoiceProxy

功能说明
多选代理是用于Android开发中的列表项多选处理的解耦工具,提供零介入实现多选、单选、普通列表界面切换的功能,包括选择结果集的提取

使用方法
1.查找ListView控件
mListView = (ListView) findViewById(R.id.listView);
2.定义普通的适配器
mBaseAdapter = new StringAdapter(this, mDates);
3.定义多选代理
mMultiChoiceProxy = new MultiChoiceProxy(this);

4.代理ListView 和 Adapter
multiChoiceProxy.adapterProxy(mBaseAdapter, mListView);//使用默认选择效果的代理适配器
multiChoiceProxy.adapterProxy(mBaseAdapter, mListView, false);//不使用默认选择效果的代理适配器,返回的View就是mBaseAdapter 生成的View

设置选择状态变化监听器【可选】
multiChoiceProxy.setOnSelectedChangeListener(this);

恢复保存的状态【可选】
multiChoiceProxy.restoreState(savedInstanceState);
保存适配器状态【可选】
multiChoiceProxy.saveState(outState);

设置多选模式【可选】
multiChoiceProxy.setMultiMode(SelectMode.Multi);
设置单选模式【可选】
multiChoiceProxy.setMultiMode(SelectMode.Single);
关闭选择模式【可选】
multiChoiceProxy.setMultiMode(SelectMode.NONE);

全选
multiChoiceProxy.selectAll();
选择前5项
multiChoiceProxy.selectCount(5);
清空选择项
multiChoiceProxy.cancelAll();
获取已经选择的数据【可选】
List items = multiChoiceProxy.getSelectedItems();
获取已经选择的数据,按照列表顺序【可选】
List items = multiChoiceProxy.getOrderedSelectedItems();
获取已经选择的个数【可选】
multiChoiceProxy.getCheckedItemCount();
是否是选择模式 multiChoiceProxy.isSelectFlag();
第6项是否被选中 multiChoiceProxy.isChecked(5);

About

多选代理是用于Android开发中的列表项多选处理的解耦工具,提供零介入实现多选、单选、普通列表界面切换的功能,包括选择结果集的提取

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages