@Override
 public void setMultiChoiceModeListener(MultiChoiceModeListener listener) {
   multiChoiceModeListenerDelegate = listener;
   if (listener == null) {
     super.setMultiChoiceModeListener(null);
   } else {
     super.setMultiChoiceModeListener(multiChoiceModeListenerWrapper);
   }
 }
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   ListView lv = (ListView) inflater.inflate(R.layout.listview, container, false);
   lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
   lv.setMultiChoiceModeListener(new OnCabMultiChoiceModeListener());
   return lv;
 }
  @Override
  public void onCreate(Bundle savedState) {
    super.onCreate(savedState);

    thumbSize = getResources().getInteger(R.integer.config_list_thumb_size);

    if (savedState != null) {
      String cropTempPath = savedState.getString("crop_temp");
      if (cropTempPath != null) cropTemp = new File(cropTempPath);
      pickedRawContact = savedState.getInt("picked_raw_contact", 0);
    }

    // Initialize cache directory

    new File(getCacheDir(), DISK_CACHE_DIR).mkdir();

    unchangedThumb = new BitmapDrawable(getResources(), Bitmap.createBitmap(1, 1, Config.ALPHA_8));

    setContentView(R.layout.activity_assign_contact_photo);
    contactList = (ListView) findViewById(R.id.contactList);
    emptyList = (TextView) findViewById(R.id.empty);
    loadingProgress = (ProgressBar) findViewById(R.id.loading);

    contactList.setEmptyView(loadingProgress);
    contactList.setAdapter(new ContactAdapter());
    contactList.setDividerHeight(1);
    contactList.setMultiChoiceModeListener(new ContactListMultiChoiceModeListener());
    contactList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);

    getActionBar().setDisplayHomeAsUpEnabled(true);
    account = getIntent().getStringExtra("account");
    setTitle(account);

    thumbMemCache = new SparseArray<Drawable>();
    asyncTasks = new HashSet<AsyncTask<?, ?, ?>>();
    defaultThumb = getResources().getDrawable(R.drawable.new_picture);

    contactList.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {

            pickedRawContact = ((Contact) contactList.getItemAtPosition(position)).rawContactId;
            Intent intent = new Intent();

            // We only really accept PNG and JPEG but the activities registered for
            // the intended action only accept the generic form of the mime type. We
            // will check for our constraints after the image is picked.

            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(
                Intent.createChooser(intent, getResources().getString(R.string.select_picture)),
                REQ_CODE_PICK_IMAGE);
          }
        });
  }
 @Override
 public void onActivityCreated(final Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   setHasOptionsMenu(true);
   mResolver = getContentResolver();
   final ListView listView = getListView();
   listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
   listView.setMultiChoiceModeListener(this);
   getLoaderManager().initLoader(0, null, this);
   setRefreshEnabled(false);
   showProgress();
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_searchable_students, container, false);

    this.list = (ListView) v.findViewById(R.id.fragStud_listViewStudents);
    this.search = (EditText) v.findViewById(R.id.fragStud_textSearch);

    search.addTextChangedListener(this);

    adapter = new StudentAddAdapter(getActivity(), lecture, list);
    adapter.load(getActivity());

    list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    list.setAdapter(adapter);

    LectureDetailMultiChoiceListener choiceListener =
        new LectureDetailMultiChoiceListener(
            getActivity(),
            LectureDetailMultiChoiceListener.CAB_MODE_ADD_LECTURE_STUDENTS,
            list,
            adapter,
            lecture);

    choiceListener.setOnSuccessListener(
        new OnSuccessListener() {
          @Override
          public void onSuccess() {
            if (listener != null) {
              listener.onStudentsAdded();
            }
          }
        });

    list.setMultiChoiceModeListener(choiceListener);

    return v;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);

    // Instantiate lists
    tasks = new ArrayList<>();
    tempBookList = new ArrayList<>();
    swipe = new SwipeRefreshLayout(getActivity());

    // Instantiate listview
    list = new ListView(getActivity());

    // Initiate progressbar for loading
    pb = new ProgressBar(getActivity()); // Init the progressbar
    pb.setId(1); // Give pb an id
    pb.setVisibility(View.INVISIBLE); // Set progressbar visibility

    // Set details list
    list.setBackgroundColor(Color.WHITE);
    list.setMultiChoiceModeListener(multiChoiceHandler);
    list.setOnItemClickListener(onItemClickHandler);
    list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);

    swipe.setOnRefreshListener(refreshListener);

    try {
      requestData(BookshelfConstants.CONNECTION_URI);
    } catch (JSONException e) {
      e.printStackTrace();
    }

    swipe.addView(list);

    return swipe;
  }
  @TargetApi(11)
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle saveInstanceState) {
    // method 1:
    View v = inflater.inflate(R.layout.fragment_list_view, parent, false);

    ListView listView = (ListView) v.findViewById(android.R.id.list);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      // use floating context menus on Froyo and Gingerbread
      registerForContextMenu(listView);
    } else {
      // Use contextual action bar on Honeycomb and higher
      listView.setChoiceMode(listView.CHOICE_MODE_MULTIPLE_MODAL);
      listView.setMultiChoiceModeListener(
          new MultiChoiceModeListener() {

            @Override
            public boolean onActionItemClicked(android.view.ActionMode mode, MenuItem item) {
              // TODO Auto-generated method stub
              switch (item.getItemId()) {
                case R.id.menu_item_delete_crime:
                  CrimeAdapter adapter = (CrimeAdapter) getListAdapter();
                  CrimeLab crimelab = CrimeLab.get(getActivity());

                  for (int i = adapter.getCount() - 1; i >= 0; i--) {
                    if (getListView().isItemChecked(i)) {
                      crimelab.deleteCrime(adapter.getItem(i));
                    }
                  }
                  mode.finish();
                  adapter.notifyDataSetChanged();
                  return true;
                default:
                  return false;
              }
            }

            @Override
            public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) {
              // TODO Auto-generated method stub
              MenuInflater inflater = mode.getMenuInflater();
              inflater.inflate(R.menu.crime_list_item_context, menu);
              return true;
            }

            @Override
            public void onDestroyActionMode(android.view.ActionMode arg0) {
              // TODO Auto-generated method stub

            }

            @Override
            public boolean onPrepareActionMode(android.view.ActionMode arg0, Menu arg1) {
              // TODO Auto-generated method stub
              return false;
            }

            @Override
            public void onItemCheckedStateChanged(
                android.view.ActionMode mode, int position, long id, boolean checked) {
              // TODO Auto-generated method stub

            }
          });
    }

    return v;
  }
Example #8
0
 private void installContextMenuForDictsList() {
   ListView listView = getListView();
   listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
   listView.setMultiChoiceModeListener(dictsListListener);
 }
  private void configurarLvFilmes() {
    filmes = new ArrayList<>();

    adapterFilmes =
        new ArrayAdapter<Filme>(this, android.R.layout.simple_list_item_activated_1, filmes);

    lvFilmes.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    lvFilmes.setAdapter(adapterFilmes);

    lvFilmes.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Filme filme = (Filme) parent.getItemAtPosition(position);
            long filmeId = filmeDao.getId(filme);

            Intent i = new Intent(MainActivity.this, FormActivity.class);
            i.putExtra(PARAM_FILME_ID, filmeId);
            startActivity(i);
          }
        });

    lvFilmes.setMultiChoiceModeListener(
        new AbsListView.MultiChoiceModeListener() {

          ArrayList<Filme> filmesSelecionados = new ArrayList<>();

          @Override
          public void onItemCheckedStateChanged(
              ActionMode mode, int position, long id, boolean checked) {
            int count = lvFilmes.getCheckedItemCount();
            mode.setTitle(Integer.toString(count));

            Filme filme = filmes.get(position);

            if (checked) {
              filmesSelecionados.add(filme);
            } else {
              filmesSelecionados.remove(filme);
            }
          }

          @Override
          public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.menu_filmes, menu);
            return true;
          }

          @Override
          public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
          }

          @Override
          public boolean onActionItemClicked(final ActionMode mode, MenuItem item) {
            int id = item.getItemId();

            if (id == R.id.menu_excluir_filmes) {

              AlertDialog alert =
                  new AlertDialog.Builder(MainActivity.this)
                      .setTitle(R.string.excluir_filmes)
                      .setMessage(R.string.confirma_exclusao)
                      .setPositiveButton(
                          R.string.sim,
                          new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                              for (Filme filme : filmesSelecionados) {
                                filmeDao.excluir(filme);
                              }
                              mode.finish();
                              carregarFilmes();
                            }
                          })
                      .setNegativeButton(
                          R.string.nao,
                          new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {}
                          })
                      .create();

              alert.show();
              return true;
            }

            return false;
          }

          @Override
          public void onDestroyActionMode(ActionMode mode) {
            filmesSelecionados.clear();
          }
        });
  }
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_crime_list, parent, false);
    // 新增crime
    newCrime = (Button) v.findViewById(R.id.button_new_crime);
    newCrime.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Crime crime = new Crime();
            CrimeLab.get(getActivity()).addCrime(crime);
            updateUI();
            mCallbacks.onCrimeSelected(crime);
          }
        });

    // 登记listView试图,以便弹出上下文菜单
    ListView listView = (ListView) v.findViewById(android.R.id.list);
    // 低版本用浮动上下文菜单
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      registerForContextMenu(listView);
    } else { // 高版本用上下文操作栏
      listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
      listView.setMultiChoiceModeListener(
          new MultiChoiceModeListener() {

            public void onItemCheckedStateChanged(
                ActionMode mode, int position, long id, boolean checked) {}

            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
              MenuInflater inflater = mode.getMenuInflater();
              inflater.inflate(R.menu.crime_list_item_context, menu);
              return true;
            }

            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
              return false;
            }

            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
              switch (item.getItemId()) {
                case R.id.menu_item_delete_crime:
                  CrimeAdapter adapter = (CrimeAdapter) getListAdapter();
                  CrimeLab crimeLab = CrimeLab.get(getActivity());
                  for (int i = adapter.getCount() - 1; i >= 0; i--) {
                    if (getListView().isItemChecked(i)) {
                      Crime mCrime = adapter.getItem(i);
                      // 一定要记得删除照片
                      if (mCrime.getPhoto() != null) {
                        // 获取照片的绝对保存路径
                        String filePath =
                            getActivity()
                                .getFileStreamPath(mCrime.getPhoto().getFilename())
                                .getAbsolutePath();
                        CrimeFragment.deleteFile(filePath);
                        mCrime.deletePhoto();
                      }
                      crimeLab.deleteCrime(mCrime);
                    }
                  }
                  mCallbacks.onCrimeDeleted();
                  mode.finish();
                  // adapter.notifyDataSetChanged();
                  updateUI();
                  return true;
                case R.id.menu_item_add_crime:
                  Crime crime = new Crime();
                  CrimeLab.get(getActivity()).addCrime(crime);
                  updateUI();
                  mCallbacks.onCrimeSelected(crime);
                  mode.finish();
                  return true;
                default:
                  return false;
              }
            }

            public void onDestroyActionMode(ActionMode mode) {}
          });
    }
    /*   ********************************************************************        */
    return v;
  }
  @TargetApi(11)
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View v = super.onCreateView(inflater, parent, savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      if (mSubtitleVisible) {
        getActivity().getActionBar().setSubtitle(R.string.subtitle);
      }
    }

    ListView listView = (ListView) v.findViewById(android.R.id.list);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      // floating context menu for pre-honeycomb devices
      registerForContextMenu(listView);
    } else {
      // contextual action bar for others
      listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
      listView.setMultiChoiceModeListener(
          new MultiChoiceModeListener() {

            @Override
            public boolean onPrepareActionMode(ActionMode arg0, Menu arg1) {
              // Does nothing
              return false;
            }

            @Override
            public void onDestroyActionMode(ActionMode arg0) {
              // Does nothing

            }

            @Override
            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
              MenuInflater inflater = mode.getMenuInflater();
              inflater.inflate(R.menu.crime_list_item_context, menu);
              return true;
            }

            @Override
            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
              switch (item.getItemId()) {
                case R.id.menu_item_delete_crime:
                  CrimeAdapter adapter = (CrimeAdapter) getListAdapter();
                  CrimeLab crimes = CrimeLab.get(getActivity());
                  for (int i = adapter.getCount() - 1; i >= 0; i--) {
                    if (getListView().isItemChecked(i)) {
                      crimes.deleteCrime(adapter.getItem(i));
                    }
                  }
                  mode.finish();
                  adapter.notifyDataSetChanged();
                  return true;
                default:
                  return false;
              }
            }

            @Override
            public void onItemCheckedStateChanged(
                ActionMode mode, int position, long id, boolean checked) {
              // Does nothing

            }
          });
    }

    return v;
  }
Example #12
0
  public void onCreate(Bundle saved) {
    super.onCreate(saved);

    c = 0;

    // Service
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 24);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);

    Intent intent = new Intent(Sunday.this, Receiver.class);
    pendingIntent = PendingIntent.getBroadcast(Sunday.this, 0, intent, 0);
    AlarmManager alarManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    alarManager.set(AlarmManager.RTC, calendar.getTimeInMillis(), pendingIntent);
    setContentView(R.layout.drawer);

    someData = getSharedPreferences(filename, 0);
    content = (ListView) findViewById(R.id.content_frame);
    drawerlist = (ListView) findViewById(R.id.left_drawer);
    drawerlayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    TaskAdapter1 adapter_drawer = new TaskAdapter1(this, menu);
    drawerlist.setAdapter(adapter_drawer);

    mySQL = new SundaySQL(Sunday.this);
    mySQL.Open();
    values = mySQL.getData();
    // mySQL.Close();
    final TaskAdapter adapter = new TaskAdapter(this, values);
    Notification();
    content.setEmptyView(findViewById(android.R.id.empty));
    content.setAdapter(adapter);
    Button b = (Button) findViewById(android.R.id.empty);
    b.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent i = new Intent(Sunday.this, SundayActivity.class);
            startActivity(i);
          }
        });

    drawerlist.setOnItemClickListener(this);
    content.setOnItemClickListener(this);
    content.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    content.setMultiChoiceModeListener(this);
    getActionBar().setTitle("Sunday");

    // Navigation-UP-Drawer
    drawertoggle =
        new ActionBarDrawerToggle(
            this, drawerlayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {

          /** Called when a drawer has settled in a completely closed state. */
          public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            getActionBar().setTitle("Sunday");
            invalidateOptionsMenu();
          }

          /** Called when a drawer has settled in a completely open state. */
          public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            getActionBar().setTitle(R.string.app_name);
            invalidateOptionsMenu();
          }
        };
    getActionBar().setDisplayHomeAsUpEnabled(true);
    drawerlayout.setDrawerListener(drawertoggle);
    drawerlayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    drawerlayout.setFocusableInTouchMode(false);

    // Swipe-to-Dismiss
    SwipeDismissListViewTouchListener touchListener =
        new SwipeDismissListViewTouchListener(
            content,
            new SwipeDismissListViewTouchListener.DismissCallbacks() {

              @Override
              public boolean canDismiss(int position) {
                // TODO Auto-generated method stub
                return true;
              }

              @Override
              public void onDismiss(ListView listView, int[] reverseSortedPositions) {
                // TODO Auto-generated method stub
                final SundaySQL mySQL_del = new SundaySQL(Sunday.this);
                mySQL_del.Open();
                String[] values_before = mySQL_del.getData();
                for (int position : reverseSortedPositions) {

                  mySQL_del.DeleteEntry(values_before[position], mySQL_del.getID(position));
                }
                String[] values_after = mySQL_del.getData();
                mySQL_del.Close();
                onCreate(new Bundle());
                if (values_after.length == 0) {
                  nm.cancel(0);
                }
              }
            });
    content.setOnTouchListener(touchListener);
  }
Example #13
0
  /* (non-Javadoc)
   * @see android.app.Fragment#onActivityCreated(android.os.Bundle)
   */
  @Override
  public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    adapterMatchList = new MatchListAdapter(getActivity(), matchs, this);
    setListAdapter(adapterMatchList);

    listView = getListView();
    listView.setOnItemClickListener(this);
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(
        new MultiChoiceModeListener() {

          @Override
          public void onItemCheckedStateChanged(
              final ActionMode mode, final int position, final long id, final boolean checked) {
            Integer checkedItemCount = listView.getCheckedItemCount();
            countSelected.setTitle(checkedItemCount.toString());
          }

          @Override
          public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
            switch (item.getItemId()) {
              case R.id.contextual_deleteMatchs:
                ModelController modelController = ModelController.getInstance();
                MatchModel matchModel = modelController.getMatchModel(getActivity());
                matchModel.deleteMatchs(getCheckedMatchs());
                mode.finish();
                return true;
              default:
                return false;
            }
          }

          private List<Match> getCheckedMatchs() {
            List<Match> checkedMatchs = new ArrayList<Match>();
            SparseBooleanArray checkedItems = listView.getCheckedItemPositions();
            if (checkedItems == null) {
              return null;
            }

            int checkedItemsCount = checkedItems.size();
            for (int i = 0; i < checkedItemsCount; i++) {
              if (checkedItems.valueAt(i)) {
                int position = checkedItems.keyAt(i);
                Match match = adapterMatchList.getItem(position);
                checkedMatchs.add(match);
              }
            }
            return checkedMatchs;
          }

          @Override
          public boolean onCreateActionMode(final ActionMode mode, final Menu menu) {
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.contextual_match, menu);
            countSelected = menu.findItem(R.id.contextual_countSelectedMatch);
            return true;
          }

          @Override
          public void onDestroyActionMode(final ActionMode mode) {}

          @Override
          public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) {
            return false;
          }
        });
  }
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {

    View v = super.onCreateView(inflater, parent, savedInstanceState);
    if (subtitleVisability) {
      getActivity().getActionBar().setSubtitle(R.string.Subtitle);
    }

    ListView listView = (ListView) v.findViewById(android.R.id.list);
    // registerForContextMenu(listView);
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(
        new AbsListView.MultiChoiceModeListener() {
          @Override
          public void onItemCheckedStateChanged(
              ActionMode mode, int position, long id, boolean checked) {}

          @Override
          public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.memory_list_item_context, menu);
            return true;
          }

          @Override
          public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
          }

          @Override
          public boolean onActionItemClicked(ActionMode mode, MenuItem item) {

            switch (item.getItemId()) {
              case R.id.menu_item_delete_memory:
                MemoryAdapter memoryAdapter = (MemoryAdapter) getListAdapter();

                for (int i = 0; i < memoryAdapter.getCount(); ++i) {
                  if (getListView().isItemChecked(i)) {
                    try {
                      MemoryList.get(getActivity()).deleteMemory(memoryAdapter.getItem(i));
                    } catch (IOException e) {
                      e.printStackTrace();
                    } catch (JSONException e) {
                      e.printStackTrace();
                    }
                  }
                }
                mode.finish();
                memoryAdapter.notifyDataSetChanged();
                return true;

              default:
                return false;
            }
          }

          @Override
          public void onDestroyActionMode(ActionMode mode) {}
        });
    return v;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_new_conversation);

    contactsHeader = (TextView) findViewById(R.id.contacts_header);
    createGroupButton = (Button) findViewById(R.id.button_conversation);
    search = (EditText) findViewById(R.id.new_conversation_search);
    search.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            searchString = search.getText().toString();
            updateAggregatedContacts();
          }

          @Override
          public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

          }
        });

    contactsView = (ListView) findViewById(R.id.contactList);
    contactsAdapter =
        new ArrayAdapter<Contact>(getApplicationContext(), R.layout.contact, aggregatedContacts) {
          @Override
          public View getView(int position, View view, ViewGroup parent) {
            LayoutInflater inflater =
                (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            Contact contact = getItem(position);
            if (view == null) {
              view = (View) inflater.inflate(R.layout.contact, null);
            }

            ((TextView) view.findViewById(R.id.contact_display_name))
                .setText(getItem(position).getDisplayName());
            TextView contactJid = (TextView) view.findViewById(R.id.contact_jid);
            contactJid.setText(contact.getJid());
            ImageView imageView = (ImageView) view.findViewById(R.id.contact_photo);
            imageView.setImageBitmap(
                UIHelper.getContactPicture(contact, 48, this.getContext(), false));
            return view;
          }
        };
    contactsView.setAdapter(contactsAdapter);
    contactsView.setMultiChoiceModeListener(actionModeCallback);
    contactsView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, final View view, int pos, long arg3) {
            if (!isActionMode) {
              Contact clickedContact = aggregatedContacts.get(pos);
              startConversation(clickedContact);
              // startConference();
            } else {
              actionMode.invalidate();
            }
          }
        });
    contactsView.setOnItemLongClickListener(this.onLongClickListener);
  }
  @TargetApi(11)
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View v = super.onCreateView(inflater, parent, savedInstanceState);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      if (mSubtitleVisible) {
        getActivity().getActionBar().setSubtitle(R.string.subtitle);
      }
    }

    ListView listView = (ListView) v.findViewById(android.R.id.list);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      registerForContextMenu(listView);
    } else {
      // use contextual action bar on Honeycomb and higher
      listView.setChoiceMode(listView.CHOICE_MODE_MULTIPLE_MODAL);
      listView.setMultiChoiceModeListener(
          new AbsListView.MultiChoiceModeListener() {
            @Override
            public void onItemCheckedStateChanged(
                ActionMode mode, int position, long id, boolean checked) {
              // required but not used
            }

            // ActionMode.Callback methods
            @Override
            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
              MenuInflater inflater = mode.getMenuInflater();
              inflater.inflate(R.menu.note_list_item_context, menu);
              return true;
            }

            @Override
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
              return false;
              // unused
            }

            @Override
            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
              switch (item.getItemId()) {
                case R.id.menu_item_delete_note:
                  NoteAdapter adapter = (NoteAdapter) getListAdapter();
                  NoteLab noteLab = NoteLab.get(getActivity());
                  for (int i = adapter.getCount() - 1; 1 >= 0; i--) {
                    if (getListView().isItemChecked(i)) {
                      noteLab.deleteNote(adapter.getItem(i));
                    }
                    mode.finish();
                    adapter.notifyDataSetChanged();
                    return true;
                  }

                default:
                  return false;
              }
            }

            @Override
            public void onDestroyActionMode(ActionMode mode) {}
          });
    }

    return v;
  }
  @SuppressLint({"InlinedApi", "NewApi"})
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.library_fragment, container, false);

    Log.d(TAG, "onCreateView");

    mLibraryPath = (TextView) view.findViewById(R.id.library_path);
    mList = (ListView) view.findViewById(R.id.library);
    mEmptyLibrary = view.findViewById(R.id.library_empty);

    mLibraryEmptyText = (TextView) mEmptyLibrary.findViewById(R.id.library_empty_txt);

    mList.setOnItemClickListener(oiclLibraryClick);
    mList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    mList.setMultiChoiceModeListener(
        new MultiChoiceModeListener() {
          @Override
          public boolean onActionItemClicked(ActionMode mode, android.view.MenuItem item) {
            SparseBooleanArray checkedPositions = mList.getCheckedItemPositions();

            switch (item.getItemId()) {
              case R.id.library_context_add:
                for (int i = 0; i < checkedPositions.size(); ++i) {
                  int position = checkedPositions.keyAt(i);
                  if (checkedPositions.valueAt(i)) {
                    MyLibraryItem libraryItem = mAdapters.getLast().getItem(position);
                    addSongsToPlaylist(libraryItem);
                  }
                }
                mode.finish();
                return true;
              default:
                return false;
            }
          }

          @Override
          public boolean onCreateActionMode(ActionMode mode, android.view.Menu menu) {
            android.view.MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.library_context_menu, menu);
            return true;
          }

          @Override
          public boolean onPrepareActionMode(ActionMode mode, android.view.Menu menu) {
            return false;
          }

          @Override
          public void onDestroyActionMode(ActionMode mode) {}

          @Override
          public void onItemCheckedStateChanged(
              ActionMode mode, int position, long id, boolean checked) {}
        });

    // Create the adapter
    mLibrary = new MyLibrary(getActivity());
    mLibrary.removeDatabaseIfFromOtherClementine();
    if (App.libraryDownloader == null && mLibrary.databaseExists()) {
      mLibrary.openDatabase();
      LibraryAdapter a =
          new LibraryAdapter(getActivity(), mLibrary.getArtists(), mLibrary, MyLibrary.LVL_ARTIST);
      mAdapters.add(a);
    }

    showList();

    mActionBar.setTitle("");
    mActionBar.setSubtitle("");

    setHasOptionsMenu(true);

    return view;
  }
  /** When view is created. */
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // Enabling batch contextual actions in the ListView.
    final ListView listView = getListView();
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);

    // AbsListView.MultiChoiceModeListener interface.
    listView.setMultiChoiceModeListener(
        new MultiChoiceModeListener() {

          @Override
          public void onItemCheckedStateChanged(
              ActionMode mode, int position, long id, boolean checked) {
            // Here you can do something when items are selected/de-selected,
            // such as update the title in the CAB.
            if (mAdapter.getItem(position) instanceof Segment) {
              mAdapter.toggleSelection(position);
              mode.setTitle(mAdapter.getSelectedIds().size() + " Selected");
            } else if (mAdapter.getSelectedIds().size() == 0) {
              mode.finish();
            }
          }

          @Override
          public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            // Respond to clicks on the actions in the CAB
            switch (item.getItemId()) {
              case R.id.tracklist_delete:
                new AlertDialog.Builder(getActivity())
                    .setTitle(R.string.delete_segment)
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setMessage(getResources().getString(R.string.delete_segment_selected_hint))
                    .setCancelable(true)
                    .setPositiveButton(
                        android.R.string.yes,
                        new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialog, int which) {
                            // Calls getSelectedIds method from ListViewAdapter Class
                            SparseBooleanArray selected = mAdapter.getSelectedIds();
                            // Captures all selected ids with a loop
                            for (int i = (selected.size() - 1); i >= 0; i--) {
                              if (selected.valueAt(i)) {
                                Segment selectedItem = mAdapter.getItem(selected.keyAt(i));
                                if (!DBModel.deleteSegment(
                                    getActivity(), ((Segment) selectedItem).getId())) {
                                  Toast.makeText(
                                          getActivity(),
                                          getString(R.string.segment_was_not_deleted)
                                              + " ("
                                              + ((Segment) selectedItem).getName()
                                              + ")",
                                          Toast.LENGTH_LONG)
                                      .show();
                                } else {
                                  mAdapter.remove(selectedItem);
                                }
                              }
                            }
                            mAdapter.removeSelection();
                          }
                        })
                    .setNegativeButton(
                        android.R.string.no,
                        new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialog, int which) {
                            mAdapter.removeSelection();
                            dialog.cancel();
                          }
                        })
                    .create()
                    .show();

                mode.finish(); // Action picked, so close the CAB
                return true;
              default:
                return false;
            }
          }

          @Override
          public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            // Inflate the menu for the CAB
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.segment_list_context_menu, menu);
            return true;
          }

          @Override
          public void onDestroyActionMode(ActionMode mode) {
            // Here you can make any necessary updates to the activity when
            // the CAB is removed. By default, selected items are deselected/unchecked.
            // mAdapter.removeSelection();
          }

          @Override
          public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            // Here you can perform updates to the CAB due to
            // an invalidate() request
            return false;
          }
        });
  }