35
35
import android .view .TouchDelegate ;
36
36
import android .view .View ;
37
37
import android .view .ViewGroup ;
38
- import android .widget .CheckBox ;
39
- import android .widget .CompoundButton ;
38
+ import android .widget .*;
40
39
import android .widget .CompoundButton .OnCheckedChangeListener ;
41
- import android .widget .ListView ;
42
- import android .widget .TextView ;
43
40
import com .actionbarsherlock .app .ActionBar ;
44
41
import com .actionbarsherlock .app .SherlockListFragment ;
45
42
import com .actionbarsherlock .view .ActionMode ;
65
62
*
66
63
*/
67
64
public class TransactionsListFragment extends SherlockListFragment implements
68
- Refreshable , LoaderCallbacks <Cursor > {
65
+ Refreshable , LoaderCallbacks <Cursor >, AdapterView . OnItemLongClickListener {
69
66
70
67
/**
71
68
* Logging tag
@@ -76,7 +73,6 @@ public class TransactionsListFragment extends SherlockListFragment implements
76
73
private SimpleCursorAdapter mCursorAdapter ;
77
74
private ActionMode mActionMode = null ;
78
75
private boolean mInEditMode = false ;
79
- // private long mAccountID;
80
76
private String mAccountUID ;
81
77
82
78
/**
@@ -162,6 +158,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
162
158
aBar .setDisplayHomeAsUpEnabled (true );
163
159
164
160
getListView ().setChoiceMode (ListView .CHOICE_MODE_MULTIPLE );
161
+ getListView ().setOnItemLongClickListener (this );
165
162
setHasOptionsMenu (true );
166
163
}
167
164
@@ -223,7 +220,16 @@ public void onListItemClick(ListView l, View v, int position, long id) {
223
220
}
224
221
mTransactionEditListener .editTransaction (mTransactionsDbAdapter .getUID (id ));
225
222
}
226
-
223
+
224
+ @ Override
225
+ public boolean onItemLongClick (AdapterView <?> adapterView , View view , int position , long id ) {
226
+ getListView ().setItemChecked (position , true );
227
+ CheckBox checkbox = (CheckBox ) view .findViewById (R .id .checkbox_parent_account );
228
+ checkbox .setChecked (true );
229
+ startActionMode ();
230
+ return true ;
231
+ }
232
+
227
233
@ Override
228
234
public void onCreateOptionsMenu (Menu menu , MenuInflater inflater ) {
229
235
inflater .inflate (R .menu .transactions_list_actions , menu );
0 commit comments