├── .classpath
├── .project
├── .settings
└── org.eclipse.jdt.core.prefs
├── AndroidManifest.xml
├── README
├── bin
├── Planets.apk
├── classes.dex
├── classes
│ └── com
│ │ └── windrealm
│ │ └── android
│ │ ├── MultiSelectList$1.class
│ │ ├── MultiSelectList$SelectArralAdapter$1.class
│ │ ├── MultiSelectList$SelectArralAdapter.class
│ │ ├── MultiSelectList$SelectViewHolder.class
│ │ ├── MultiSelectList$mItems.class
│ │ ├── MultiSelectList.class
│ │ ├── R$attr.class
│ │ ├── R$drawable.class
│ │ ├── R$id.class
│ │ ├── R$layout.class
│ │ ├── R$string.class
│ │ └── R.class
├── res
│ ├── drawable-hdpi
│ │ └── icon.png
│ ├── drawable-ldpi
│ │ └── icon.png
│ └── drawable-mdpi
│ │ └── icon.png
└── resources.ap_
├── gen
└── com
│ └── windrealm
│ └── android
│ └── R.java
├── project.properties
├── readme.txt
├── res
├── drawable-hdpi
│ └── icon.png
├── drawable-ldpi
│ └── icon.png
├── drawable-mdpi
│ └── icon.png
├── layout
│ ├── main.xml
│ └── simplerow.xml
└── values
│ └── strings.xml
└── src
└── com
└── windrealm
└── android
└── MultiSelectList.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Planets
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | #Wed Jul 28 03:35:39 SGT 2010
2 | eclipse.preferences.version=1
3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6 | org.eclipse.jdt.core.compiler.compliance=1.6
7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.source=1.6
13 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | Multi-Selection ListView ANDROID with CheckBox
2 | =========================
3 |
4 | ANDROID - Multi-Selection ListView with CheckBox
5 |
6 | ==================
7 |
8 | This is sample code for Multi-Selection ListView with CheckBox.
9 |
10 | More detail check this
11 |
12 | 1. http://dj-android.blogspot.in/2012/04/milti-selection-listview-android-with.html
13 | 2. http://dj-android.blogspot.in/2013/02/multi-selection-listview-android-with.html
14 |
15 | Dhaval Sodha Parmar
16 |
17 | http://dj-android.blogspot.in/
18 |
--------------------------------------------------------------------------------
/bin/Planets.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/Planets.apk
--------------------------------------------------------------------------------
/bin/classes.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/classes.dex
--------------------------------------------------------------------------------
/bin/classes/com/windrealm/android/MultiSelectList$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/classes/com/windrealm/android/MultiSelectList$1.class
--------------------------------------------------------------------------------
/bin/classes/com/windrealm/android/MultiSelectList$SelectArralAdapter$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/classes/com/windrealm/android/MultiSelectList$SelectArralAdapter$1.class
--------------------------------------------------------------------------------
/bin/classes/com/windrealm/android/MultiSelectList$SelectArralAdapter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/classes/com/windrealm/android/MultiSelectList$SelectArralAdapter.class
--------------------------------------------------------------------------------
/bin/classes/com/windrealm/android/MultiSelectList$SelectViewHolder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/classes/com/windrealm/android/MultiSelectList$SelectViewHolder.class
--------------------------------------------------------------------------------
/bin/classes/com/windrealm/android/MultiSelectList$mItems.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/classes/com/windrealm/android/MultiSelectList$mItems.class
--------------------------------------------------------------------------------
/bin/classes/com/windrealm/android/MultiSelectList.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/classes/com/windrealm/android/MultiSelectList.class
--------------------------------------------------------------------------------
/bin/classes/com/windrealm/android/R$attr.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/classes/com/windrealm/android/R$attr.class
--------------------------------------------------------------------------------
/bin/classes/com/windrealm/android/R$drawable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/classes/com/windrealm/android/R$drawable.class
--------------------------------------------------------------------------------
/bin/classes/com/windrealm/android/R$id.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/classes/com/windrealm/android/R$id.class
--------------------------------------------------------------------------------
/bin/classes/com/windrealm/android/R$layout.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/classes/com/windrealm/android/R$layout.class
--------------------------------------------------------------------------------
/bin/classes/com/windrealm/android/R$string.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/classes/com/windrealm/android/R$string.class
--------------------------------------------------------------------------------
/bin/classes/com/windrealm/android/R.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/classes/com/windrealm/android/R.class
--------------------------------------------------------------------------------
/bin/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/bin/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/bin/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/bin/resources.ap_:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/bin/resources.ap_
--------------------------------------------------------------------------------
/gen/com/windrealm/android/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.windrealm.android;
9 |
10 | public final class R {
11 | public static final class attr {
12 | }
13 | public static final class drawable {
14 | public static final int icon=0x7f020000;
15 | }
16 | public static final class id {
17 | public static final int CheckBox01=0x7f050002;
18 | public static final int mainListView=0x7f050000;
19 | public static final int rowTextView=0x7f050001;
20 | }
21 | public static final class layout {
22 | public static final int main=0x7f030000;
23 | public static final int simplerow=0x7f030001;
24 | }
25 | public static final class string {
26 | public static final int app_name=0x7f040001;
27 | public static final int hello=0x7f040000;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Indicates whether an apk should be generated for each density.
11 | split.density=false
12 | # Project target.
13 | target=android-7
14 |
--------------------------------------------------------------------------------
/readme.txt:
--------------------------------------------------------------------------------
1 | Originally downloaded from windrealm.com
2 | Author: Andrew Lim
--------------------------------------------------------------------------------
/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dhaval0122/Multi-Select-ListView/e43fd62227571c9db2699d49ccb536c3528f85b0/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/res/layout/simplerow.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
16 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello World, SimpleListViewActivity!
4 | Milti-Selection List
5 |
6 |
--------------------------------------------------------------------------------
/src/com/windrealm/android/MultiSelectList.java:
--------------------------------------------------------------------------------
1 | package com.windrealm.android;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import android.app.Activity;
7 | import android.content.Context;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 | import android.view.LayoutInflater;
11 | import android.view.Menu;
12 | import android.view.MenuItem;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.widget.AdapterView;
16 | import android.widget.ArrayAdapter;
17 | import android.widget.CheckBox;
18 | import android.widget.ListView;
19 | import android.widget.TextView;
20 |
21 | public class MultiSelectList extends Activity {
22 |
23 | private ListView mainListView;
24 | private mItems[] itemss;
25 | private ArrayAdapter listAdapter;
26 | ArrayList checked = new ArrayList();
27 |
28 | /** Called when the activity is first created. */
29 | @Override
30 | public void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.main);
33 |
34 | // Find the ListView resource.
35 | mainListView = (ListView) findViewById(R.id.mainListView);
36 |
37 | // When item is tapped, toggle checked properties of CheckBox and
38 | // Planet.
39 | mainListView
40 | .setOnItemClickListener(new AdapterView.OnItemClickListener() {
41 | @Override
42 | public void onItemClick(AdapterView> parent, View item,
43 | int position, long id) {
44 | mItems planet = listAdapter.getItem(position);
45 | planet.toggleChecked();
46 | SelectViewHolder viewHolder = (SelectViewHolder) item
47 | .getTag();
48 | viewHolder.getCheckBox().setChecked(planet.isChecked());
49 |
50 | }
51 | });
52 |
53 | // Create and populate planets.
54 | itemss = (mItems[]) getLastNonConfigurationInstance();
55 |
56 | ArrayList planetList = new ArrayList();
57 |
58 | planetList.add(new mItems("DJ-Android"));
59 | planetList.add(new mItems("Android"));
60 | planetList.add(new mItems("iPhone"));
61 | planetList.add(new mItems("BlackBerry"));
62 | planetList.add(new mItems("Java"));
63 | planetList.add(new mItems("PHP"));
64 | planetList.add(new mItems(".Net"));
65 |
66 | // Set our custom array adapter as the ListView's adapter.
67 | listAdapter = new SelectArralAdapter(this, planetList);
68 | mainListView.setAdapter(listAdapter);
69 | }
70 |
71 | @Override
72 | public boolean onCreateOptionsMenu(Menu menu) {
73 | // TODO Auto-generated method stub
74 | menu.add(0, 1, Menu.NONE, "Products");
75 | return super.onCreateOptionsMenu(menu);
76 | }
77 |
78 | @Override
79 | public boolean onOptionsItemSelected(MenuItem item) {
80 | // TODO Auto-generated method stub
81 | switch (item.getItemId()) {
82 | case 1:
83 |
84 | for (int i = 0; i < checked.size(); i++) {
85 | Log.d("pos : ", "" + checked.get(i));
86 | }
87 | break;
88 | }
89 | return super.onOptionsItemSelected(item);
90 | }
91 |
92 | /** Holds planet data. */
93 | private static class mItems {
94 | private String name = "";
95 | private boolean checked = false;
96 |
97 | public mItems() {
98 | }
99 |
100 | public mItems(String name) {
101 | this.name = name;
102 | }
103 |
104 | public mItems(String name, boolean checked) {
105 | this.name = name;
106 | this.checked = checked;
107 | }
108 |
109 | public String getName() {
110 | return name;
111 | }
112 |
113 | public void setName(String name) {
114 | this.name = name;
115 | }
116 |
117 | public boolean isChecked() {
118 | return checked;
119 | }
120 |
121 | public void setChecked(boolean checked) {
122 | this.checked = checked;
123 | }
124 |
125 | public String toString() {
126 | return name;
127 | }
128 |
129 | public void toggleChecked() {
130 | checked = !checked;
131 | }
132 | }
133 |
134 | /** Holds child views for one row. */
135 | private static class SelectViewHolder {
136 | private CheckBox checkBox;
137 | private TextView textView;
138 |
139 | public SelectViewHolder() {
140 | }
141 |
142 | public SelectViewHolder(TextView textView, CheckBox checkBox) {
143 | this.checkBox = checkBox;
144 | this.textView = textView;
145 | }
146 |
147 | public CheckBox getCheckBox() {
148 | return checkBox;
149 | }
150 |
151 | public void setCheckBox(CheckBox checkBox) {
152 | this.checkBox = checkBox;
153 | }
154 |
155 | public TextView getTextView() {
156 | return textView;
157 | }
158 |
159 | public void setTextView(TextView textView) {
160 | this.textView = textView;
161 | }
162 | }
163 |
164 | /** Custom adapter for displaying an array of Planet objects. */
165 | private static class SelectArralAdapter extends ArrayAdapter {
166 | private LayoutInflater inflater;
167 |
168 | public SelectArralAdapter(Context context, List planetList) {
169 | super(context, R.layout.simplerow, R.id.rowTextView, planetList);
170 | // Cache the LayoutInflate to avoid asking for a new one each time.
171 | inflater = LayoutInflater.from(context);
172 | }
173 |
174 | @Override
175 | public View getView(int position, View convertView, ViewGroup parent) {
176 | // Planet to display
177 | mItems planet = (mItems) this.getItem(position);
178 |
179 | // The child views in each row.
180 | CheckBox checkBox;
181 | TextView textView;
182 |
183 | // Create a new row view
184 | if (convertView == null) {
185 | convertView = inflater.inflate(R.layout.simplerow, null);
186 |
187 | // Find the child views.
188 | textView = (TextView) convertView
189 | .findViewById(R.id.rowTextView);
190 | checkBox = (CheckBox) convertView.findViewById(R.id.CheckBox01);
191 | // Optimization: Tag the row with it's child views, so we don't
192 | // have to
193 | // call findViewById() later when we reuse the row.
194 | convertView.setTag(new SelectViewHolder(textView, checkBox));
195 | // If CheckBox is toggled, update the planet it is tagged with.
196 | checkBox.setOnClickListener(new View.OnClickListener() {
197 | public void onClick(View v) {
198 | CheckBox cb = (CheckBox) v;
199 | mItems planet = (mItems) cb.getTag();
200 | planet.setChecked(cb.isChecked());
201 | }
202 | });
203 | }
204 | // Reuse existing row view
205 | else {
206 | // Because we use a ViewHolder, we avoid having to call
207 | // findViewById().
208 | SelectViewHolder viewHolder = (SelectViewHolder) convertView
209 | .getTag();
210 | checkBox = viewHolder.getCheckBox();
211 | textView = viewHolder.getTextView();
212 | }
213 |
214 | // Tag the CheckBox with the Planet it is displaying, so that we can
215 | // access the planet in onClick() when the CheckBox is toggled.
216 | checkBox.setTag(planet);
217 | // Display planet data
218 | checkBox.setChecked(planet.isChecked());
219 | textView.setText(planet.getName());
220 | return convertView;
221 | }
222 | }
223 |
224 | public Object onRetainNonConfigurationInstance() {
225 | return itemss;
226 | }
227 | }
--------------------------------------------------------------------------------