Skip to content

Android - A ListView adapter with support for multiple choice modal selection

License

Notifications You must be signed in to change notification settings

mdabbagh88/MultiChoiceAdapter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MultiChoiceAdapter

MultiChoiceAdapter is an implementation of ListAdapter which adds support for modal multiple choice selection as in the native Gmail app.

It provides a functionality similar to that of the CHOICE_MODE_MULTIPLE_MODAL ListView mode, with two additional benefits:

  • It's easier to use, as it keeps count of the selected items, updates their background accordingly and handles checkboxes transparently.
  • It is compatible with every version of Android from 2.x. Of course, this implies that your project must use ActionBarSherlock.

Example Image

Try out the sample application:

Android app on Google Play

Or browse the source code of the sample application for a complete example of use.

Including in your project

If you’re using Eclipse with the ADT plugin you can include MultiChoiceAdapter as a library project. Create a new Android project using the library/ folder as the existing source. Then, open the properties of this new project and, in the 'Android' category, add a reference to the ActionBarSherlock library project. Finally, in your application project properties, add a reference to the created library project.

If you use maven to build your Android project you can simply add a dependency for this library.

<dependency>
    <groupId>com.github.manuelpeinado.multichoiceadapter</groupId>
    <artifactId>multichoiceadapter</artifactId>
    <version>2.2.4</version>
    <type>apklib</type>
</dependency>

Usage

Check any of the provided tutorials:

Customization

You can customize the way the adapter behaves when an item is clicked and the action mode was already active. To do so, add an item named multiChoiceAdapterStyle to your theme, and have it reference an additional style which you define like this:

<style name="MyCustomMultiChoiceAdapter">
    <item name="itemClickInActionMode">selectItem</item>
</style>

Two values are supported:

  • selectItem. Changes the selection state of the clicked item, just as if it had been long clicked. This is what the native MULTICHOICE_MODAL mode of ListView does, and what almost every app does, and thus the default value.
  • openItem. Opens the clicked item, just as if it had been clicked outside of the action mode. This is what the native Gmail app does.

Libraries used

Who's using it

  • My App List. With this app you can save installed applications in a list to restore them after flash or install a new ROM.

Does your app use MultiChoiceAdapter? If you want to be featured on this list drop me a line.

Developed By

Manuel Peinado Gallego - manuel.peinado@gmail.com

Follow me on Twitter Follow me on Twitter Follow me on Twitter
Copyright 2013 Manuel Peinado

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.

About

Android - A ListView adapter with support for multiple choice modal selection

Resources

License

Stars

Watchers

Forks

Packages

No packages published