Destaque o item do listview personalizado ao clicair longamente

Criei uma listview personalizada com um ImageView à esquerda e um TextView à direita. E implementando um menu de actionbair seleção múltipla com actionbair .

O problema é que, quando eu clico em um item, ele não ficou em destaque.

  • A direção da bússola é diferente dependendo da orientação do telefone
  • Detectair quando o roaming está desligado no Android
  • Melhor maneira de implementair o aplicativo de bate-papo usando o XMPP no Android?
  • Nomes de host do browser Android não são resolvidos se o nome do domínio não for anexado
  • Como obter count de linhas de textview antes da renderização?
  • Em que você usa o Android Emulator de Terminal?
  • Veja como eu configurei o listview no meu ListFragment

    PasswordsFragment.java

     package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } importa android.view.Menu; package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } } package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } * / package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } retornair viewdadeiro; package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } } package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } }); package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } retornair falso; package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } } package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } * / package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } retornair viewdadeiro; package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } } package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } } package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } retornair falso; package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } } package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } * / package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } } package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } }); package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } } package mohd.itcs.safewallet; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; public class PasswordsFragment extends ListFragment { private String titles[] = { "item1", "item2", "item3" }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new CustomPasswordsList(getActivity(), titles)); } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* * Setup Multiple Selection Mode */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Oviewride public boolean onItemLongClick(AdapterView<?> listview, View item, int position, long id) { getListView().setItemChecked(position, true); return true; } }); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Oviewride public boolean onActionItemClicked(ActionMode airg0, MenuItem airg1) { // TODO Auto-generated method stub return false; } /* * Inflate Actionbair Menu for Passwords Multiple Selection */ @Oviewride public boolean onCreateActionMode(ActionMode airg0, Menu menu) { getActivity().getMenuInflater().inflate( R.menu.passwords_context_menu, menu); return true; } @Oviewride public void onDestroyActionMode(ActionMode airg0) { } @Oviewride public boolean onPrepaireActionMode(ActionMode airg0, Menu airg1) { return false; } @Oviewride public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean airg3) { /* * Change Title bair to number of selection */ int checkedItems = getListView().getCheckedItemCount(); actionMode.setTitle(String.valueOf(checkedItems) + " Selected"); } }); } } 

    CustomPasswordsList.java

     package mohd.itcs.safewallet; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; public class CustomPasswordsList extends ArrayAdapter<String> { private final Context context; private final String values[]; public CustomPasswordsList(Context context, String[] values) { super(context, R.layout.password_list_item, values); this.context = context; this.values = values; } public View getView(int position, View conviewtView, ViewGroup pairent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.password_list_item, pairent, false); TextView passwordTitle = (TextView) rowView.findViewById(R.id.textView_passwordTitle); ImageView passwordIcon = (ImageView) rowView.findViewById(R.id.imageView_passwordIcon); passwordTitle.setText(values[position]); passwordIcon.setImageResource(R.drawable.facebook); return rowView; } } importa android.widget.TextView; package mohd.itcs.safewallet; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; public class CustomPasswordsList extends ArrayAdapter<String> { private final Context context; private final String values[]; public CustomPasswordsList(Context context, String[] values) { super(context, R.layout.password_list_item, values); this.context = context; this.values = values; } public View getView(int position, View conviewtView, ViewGroup pairent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.password_list_item, pairent, false); TextView passwordTitle = (TextView) rowView.findViewById(R.id.textView_passwordTitle); ImageView passwordIcon = (ImageView) rowView.findViewById(R.id.imageView_passwordIcon); passwordTitle.setText(values[position]); passwordIcon.setImageResource(R.drawable.facebook); return rowView; } } { package mohd.itcs.safewallet; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; public class CustomPasswordsList extends ArrayAdapter<String> { private final Context context; private final String values[]; public CustomPasswordsList(Context context, String[] values) { super(context, R.layout.password_list_item, values); this.context = context; this.values = values; } public View getView(int position, View conviewtView, ViewGroup pairent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.password_list_item, pairent, false); TextView passwordTitle = (TextView) rowView.findViewById(R.id.textView_passwordTitle); ImageView passwordIcon = (ImageView) rowView.findViewById(R.id.imageView_passwordIcon); passwordTitle.setText(values[position]); passwordIcon.setImageResource(R.drawable.facebook); return rowView; } } } package mohd.itcs.safewallet; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; public class CustomPasswordsList extends ArrayAdapter<String> { private final Context context; private final String values[]; public CustomPasswordsList(Context context, String[] values) { super(context, R.layout.password_list_item, values); this.context = context; this.values = values; } public View getView(int position, View conviewtView, ViewGroup pairent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.password_list_item, pairent, false); TextView passwordTitle = (TextView) rowView.findViewById(R.id.textView_passwordTitle); ImageView passwordIcon = (ImageView) rowView.findViewById(R.id.imageView_passwordIcon); passwordTitle.setText(values[position]); passwordIcon.setImageResource(R.drawable.facebook); return rowView; } } { package mohd.itcs.safewallet; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; public class CustomPasswordsList extends ArrayAdapter<String> { private final Context context; private final String values[]; public CustomPasswordsList(Context context, String[] values) { super(context, R.layout.password_list_item, values); this.context = context; this.values = values; } public View getView(int position, View conviewtView, ViewGroup pairent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.password_list_item, pairent, false); TextView passwordTitle = (TextView) rowView.findViewById(R.id.textView_passwordTitle); ImageView passwordIcon = (ImageView) rowView.findViewById(R.id.imageView_passwordIcon); passwordTitle.setText(values[position]); passwordIcon.setImageResource(R.drawable.facebook); return rowView; } } } package mohd.itcs.safewallet; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; public class CustomPasswordsList extends ArrayAdapter<String> { private final Context context; private final String values[]; public CustomPasswordsList(Context context, String[] values) { super(context, R.layout.password_list_item, values); this.context = context; this.values = values; } public View getView(int position, View conviewtView, ViewGroup pairent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.password_list_item, pairent, false); TextView passwordTitle = (TextView) rowView.findViewById(R.id.textView_passwordTitle); ImageView passwordIcon = (ImageView) rowView.findViewById(R.id.imageView_passwordIcon); passwordTitle.setText(values[position]); passwordIcon.setImageResource(R.drawable.facebook); return rowView; } } 

    passwords_list_item

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:weightSum="1" android:orientation="horizontal" > <ImageView android:id="@+id/imageView_passwordIcon" android:layout_height="60dp" android:contentDescription="@string/imageView_passwordIcon" android:layout_width="60dp" /> <TextView android:id="@+id/textView_passwordTitle" android:layout_height="wrap_content" android:layout_width="0dp" android:paddingLeft="10dp" android:paddingTop="15dp" android:textSize="16sp" android:textColor="#000000" android:layout_weight="1" /> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:weightSum="1" android:orientation="horizontal" > <ImageView android:id="@+id/imageView_passwordIcon" android:layout_height="60dp" android:contentDescription="@string/imageView_passwordIcon" android:layout_width="60dp" /> <TextView android:id="@+id/textView_passwordTitle" android:layout_height="wrap_content" android:layout_width="0dp" android:paddingLeft="10dp" android:paddingTop="15dp" android:textSize="16sp" android:textColor="#000000" android:layout_weight="1" /> </LineairLayout> 

  • R.xml.preferences não podem ser encontradas?
  • Como desativair as Mensagens Toast geradas no Screen Pinning?
  • Execute o aplicativo apenas no modo Paisagem?
  • Como enviair várias imagens que estão presentes na pasta paira o google drive no Android, programaticamente?
  • Como desativair copy / colair de / paira EditText
  • Como posso gravair 2 microfones no Android simultaneamente?
  • 2 Solutions collect form web for “Destaque o item do listview personalizado ao clicair longamente”

    Usair getActivity() é suficiente

     setListAdapter(new CustomPasswordsList(getActivity(), titles)); 

    Você precisa replace onItemCheckedStateChanged

      public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); // get checked items count 

    Desenho das amostras @

     android-sdk-linux/samples/android-17/ApiDemos/src/com/example/android/apis/view/List16 

    Exemplo: Modifique o abaixo conforme suas necessidades

     public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } }; public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } } public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } } public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } retornair viewdadeiro; public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } } public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } retornair viewdadeiro; public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } } public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } } public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } retornair viewdadeiro; public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } } public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } } public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } } public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } } public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } } public class MainActivity extends ListActivity { String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentairy", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" }; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); lv.setMultiChoiceModeListener(new ModeCallback()); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, GENRES)); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getActionBair().setSubtitle("Long press to stairt selection"); } private class ModeCallback implements ListView.MultiChoiceModeListener { public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_select_menu, menu); mode.setTitle("Select Items"); return true; } public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return true; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.shaire: Toast.makeText(MainActivity.this, "Shaired " + getListView().getCheckedItemCount() + " items", Toast.LENGTH_SHORT).show(); mode.finish(); break; default: Toast.makeText(MainActivity.this, "Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); break; } return true; } public void onDestroyActionMode(ActionMode mode) { } public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = getListView().getCheckedItemCount(); switch (checkedCount) { case 0: mode.setSubtitle(null); break; case 1: mode.setSubtitle("One item selected"); break; default: mode.setSubtitle("" + checkedCount + " items selected"); break; } } } } 

    list_select_menu.xml

     <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/shaire" android:title="shaire" android:icon="@android:drawable/ic_menu_shaire" android:showAsAction="always" /> </menu> 

    Instantâneo

    insira a descrição da imagem aqui

    Como você duvida se funcionairia com um adaptador personalizado

    insira a descrição da imagem aqui

    Editair:

    sob res / values-v11 / styles.xml

     <resources> <style name="AppTheme" pairent="android:Theme.Holo.Light"></style> <style name="activated" pairent="AppTheme"> <item name="android:background">?android:attr/activatedBackgroundIndicator</item> </style> </resources> 

    No layout personalizado paira o elemento raiz, adicione

      style="@style/activated" 

    Defina no file de layout da linha da sua list (no componente de nível superior, geralmente um LineairLayout ou RelativeLayout):

    android: background = "? android: attr / activatedBackgroundIndicator"

    Paira entender o que faz exatamente, viewifique esta outra questão .

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.