Advertisement
Guest User

Untitled

a guest
May 5th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. public void setItemChecked(int position, boolean value)
  2.  
  3. public boolean performItemClick(View view, int position, long id)
  4.  
  5. public class CustomGridView extends GridView {
  6.  
  7. public CustomGridView(Context context) {
  8. super(context);
  9. }
  10.  
  11. @Override
  12. public void setItemChecked(int position, boolean value) {
  13. Log.i(BuildConfig.LOGTAG, "CustomGridView:setItemChecked");
  14. super.setItemChecked(position, value);
  15. }
  16.  
  17. @Override
  18. public boolean performItemClick(View view, int position, long id) {
  19. Log.i(BuildConfig.LOGTAG, "CustomGridView:performItemClick");
  20. return super.performItemClick(view, position, id);
  21. }
  22. }
  23.  
  24. protected class ActionBarCallback implements GridView.MultiChoiceModeListener {
  25. @Override
  26. public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean checked) {
  27. if (checked) {
  28. mAdapter.addPosition(position, true);
  29. mAdapter.addId(id, true);
  30. } else {
  31. mAdapter.removePosition(position);
  32. mAdapter.removeId(id);
  33. }
  34.  
  35. int selectCount = mGridView.getCheckedItemCount();
  36.  
  37. String title = getResources().getQuantityString(R.plurals.pictures_selected, selectCount, selectCount);
  38. actionMode.setTitle(title);
  39. }
  40.  
  41. @Override
  42. public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
  43. MenuInflater inflater = actionMode.getMenuInflater();
  44. inflater.inflate( R.menu.picture_context, menu);
  45. return true;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement