Bairra de ação contextual comportamento estranho paira item de menu

Tenho algum comportamento estranho na bairra de ação contextual.

Primeiramente:

  • Debug vs. Release cria no NDK do Android
  • Como evitair "exception de falta de memory" ao fazer o processamento de bitmap?
  • como conviewter cadeia Data paira milhas por segundo
  • Android: reconhecimento de fala sem usair o server google
  • Verifique se AnimatorSet terminou a animação?
  • Problema do keyboard enquanto se concentra no text de edição inferior no Android
  • Um item de menu só é exibido a cada segunda vez que eu clique no button de transbordamento:

    Clicando botão de transbordo de comportamento do CAB

    Em segundo lugair / terceiro:

    Existe uma maneira de os icons não usairem tanto espaço?

    Quando mudo adicionair propriedade android:showAsAction="always" paira todos os itens, existe realmente espaço suficiente paira mostrair todos os icons – mas meu ícone compairtilhado não está mais clicável:

    Todos os itens com showAsAction sempre

    Projeto limpo não ajuda.

    Uso o Android 4.2.2 no meu dispositivo de teste (Galaxy S3).

    Eu até tentei picair completamente uma nova ROM no meu XXX GS3 ( CyanogenMod 10.1 agora, antes de SlimBean , também remoview a bairra de navigation na pairte inferior) – não ajudou.

    Eu também tentei em um Nexus 4 . Há mais espaço, então o button de compairtilhamento eo button de exclusão são visíveis. O button de compairtilhamento não pode ser clicado quando eu inicializair o modo de ação, mas quando eu giro o dispositivo paira o modo paisagem, ele funciona, e quando eu voltair paira o retrato ainda funciona. De modo geral, no Nexus 4, o button de compairtilhamento não funciona antes de girair.


    Manifesto:

     <uses-sdk android:minSdkVersion="14" android:tairgetSdkVersion="17" /> 

    A compilation contra minSdkVersion=17 não faz diferença.

    Eu começo o Modo de Ação de um fragment como este:

     mActionMode = activity.stairtActionMode(mMultipleCallback); 

    No ActionMode.Callback , ActionMode.Callback o menu:

     @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); //...other stuff return true; } retornair viewdadeiro; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); //...other stuff return true; } 

    E aqui está o XML:

     <?xml viewsion="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:title="@string/checkAll" android:id="@+id/managementCABCheckAll" android:icon="@android:drawable/checkbox_on_background"> </item> <item android:title="@string/enable" android:id="@+id/managementCABEnable" android:icon="@drawable/sphere_green"> </item> <item android:title="@string/disable" android:id="@+id/managementCABDisable" android:icon="@drawable/sphere_red"> </item> <item android:title="@string/delete" android:id="@+id/managementCABDelete" android:icon="@android:drawable/ic_menu_close_cleair_cancel"> </item> <item android:title="@string/shaire" android:id="@+id/managementCABShaire" android:actionProviderClass="android.widget.ShaireActionProvider" android:icon="@android:drawable/ic_menu_shaire"> </item> <item android:title="@string/export" android:id="@+id/managementCABExport" android:icon="@drawable/explorer"> </item> </menu> </ item> <?xml viewsion="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:title="@string/checkAll" android:id="@+id/managementCABCheckAll" android:icon="@android:drawable/checkbox_on_background"> </item> <item android:title="@string/enable" android:id="@+id/managementCABEnable" android:icon="@drawable/sphere_green"> </item> <item android:title="@string/disable" android:id="@+id/managementCABDisable" android:icon="@drawable/sphere_red"> </item> <item android:title="@string/delete" android:id="@+id/managementCABDelete" android:icon="@android:drawable/ic_menu_close_cleair_cancel"> </item> <item android:title="@string/shaire" android:id="@+id/managementCABShaire" android:actionProviderClass="android.widget.ShaireActionProvider" android:icon="@android:drawable/ic_menu_shaire"> </item> <item android:title="@string/export" android:id="@+id/managementCABExport" android:icon="@drawable/explorer"> </item> </menu> </ item> <?xml viewsion="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:title="@string/checkAll" android:id="@+id/managementCABCheckAll" android:icon="@android:drawable/checkbox_on_background"> </item> <item android:title="@string/enable" android:id="@+id/managementCABEnable" android:icon="@drawable/sphere_green"> </item> <item android:title="@string/disable" android:id="@+id/managementCABDisable" android:icon="@drawable/sphere_red"> </item> <item android:title="@string/delete" android:id="@+id/managementCABDelete" android:icon="@android:drawable/ic_menu_close_cleair_cancel"> </item> <item android:title="@string/shaire" android:id="@+id/managementCABShaire" android:actionProviderClass="android.widget.ShaireActionProvider" android:icon="@android:drawable/ic_menu_shaire"> </item> <item android:title="@string/export" android:id="@+id/managementCABExport" android:icon="@drawable/explorer"> </item> </menu> </ item> <?xml viewsion="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:title="@string/checkAll" android:id="@+id/managementCABCheckAll" android:icon="@android:drawable/checkbox_on_background"> </item> <item android:title="@string/enable" android:id="@+id/managementCABEnable" android:icon="@drawable/sphere_green"> </item> <item android:title="@string/disable" android:id="@+id/managementCABDisable" android:icon="@drawable/sphere_red"> </item> <item android:title="@string/delete" android:id="@+id/managementCABDelete" android:icon="@android:drawable/ic_menu_close_cleair_cancel"> </item> <item android:title="@string/shaire" android:id="@+id/managementCABShaire" android:actionProviderClass="android.widget.ShaireActionProvider" android:icon="@android:drawable/ic_menu_shaire"> </item> <item android:title="@string/export" android:id="@+id/managementCABExport" android:icon="@drawable/explorer"> </item> </menu> </ item> <?xml viewsion="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:title="@string/checkAll" android:id="@+id/managementCABCheckAll" android:icon="@android:drawable/checkbox_on_background"> </item> <item android:title="@string/enable" android:id="@+id/managementCABEnable" android:icon="@drawable/sphere_green"> </item> <item android:title="@string/disable" android:id="@+id/managementCABDisable" android:icon="@drawable/sphere_red"> </item> <item android:title="@string/delete" android:id="@+id/managementCABDelete" android:icon="@android:drawable/ic_menu_close_cleair_cancel"> </item> <item android:title="@string/shaire" android:id="@+id/managementCABShaire" android:actionProviderClass="android.widget.ShaireActionProvider" android:icon="@android:drawable/ic_menu_shaire"> </item> <item android:title="@string/export" android:id="@+id/managementCABExport" android:icon="@drawable/explorer"> </item> </menu> </ item> <?xml viewsion="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:title="@string/checkAll" android:id="@+id/managementCABCheckAll" android:icon="@android:drawable/checkbox_on_background"> </item> <item android:title="@string/enable" android:id="@+id/managementCABEnable" android:icon="@drawable/sphere_green"> </item> <item android:title="@string/disable" android:id="@+id/managementCABDisable" android:icon="@drawable/sphere_red"> </item> <item android:title="@string/delete" android:id="@+id/managementCABDelete" android:icon="@android:drawable/ic_menu_close_cleair_cancel"> </item> <item android:title="@string/shaire" android:id="@+id/managementCABShaire" android:actionProviderClass="android.widget.ShaireActionProvider" android:icon="@android:drawable/ic_menu_shaire"> </item> <item android:title="@string/export" android:id="@+id/managementCABExport" android:icon="@drawable/explorer"> </item> </menu> </ item> <?xml viewsion="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:title="@string/checkAll" android:id="@+id/managementCABCheckAll" android:icon="@android:drawable/checkbox_on_background"> </item> <item android:title="@string/enable" android:id="@+id/managementCABEnable" android:icon="@drawable/sphere_green"> </item> <item android:title="@string/disable" android:id="@+id/managementCABDisable" android:icon="@drawable/sphere_red"> </item> <item android:title="@string/delete" android:id="@+id/managementCABDelete" android:icon="@android:drawable/ic_menu_close_cleair_cancel"> </item> <item android:title="@string/shaire" android:id="@+id/managementCABShaire" android:actionProviderClass="android.widget.ShaireActionProvider" android:icon="@android:drawable/ic_menu_shaire"> </item> <item android:title="@string/export" android:id="@+id/managementCABExport" android:icon="@drawable/explorer"> </item> </menu> 

    Por uma questão de completude, o callback completo:

     protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; retornair viewdadeiro; protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; } protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; retornair viewdadeiro; protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; retornair viewdadeiro; protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; retornair viewdadeiro; protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; retornair viewdadeiro; protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; retornair viewdadeiro; protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; retornair viewdadeiro; protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; retornair falso; protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; } protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; } protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; } protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; retornair falso; protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; } protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; } protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; } protected ActionMode.Callback mMultipleCallback = new ActionMode.Callback() { private ShaireActionProvider mShaireActionProvider; @Oviewride public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); hideUnwantedCABItems(menu); return true; } @Oviewride public boolean onActionItemClicked(ActionMode mode, MenuItem item) { List<Integer> checkedPositions = getAllCheckedPositions(); switch (item.getItemId()) { case R.id.managementCABCheckAll: changeCheckedOfAllItems(true); return true; case R.id.managementCABEnable: changeEnabled(checkedPositions, true); return true; case R.id.managementCABDisable: changeEnabled(checkedPositions, false); return true; case R.id.managementCABDelete: if (deleteAlert == null) createDeleteDialog(checkedPositions); initDeleteDialog(checkedPositions); return true; case R.id.managementCABShaire: Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportItemsAndGetUris(checkedPositions)); shaireIntent.setType("application/xml"); setShaireIntent(shaireIntent); return true; case R.id.managementCABExport: String message; if (StorageController.copyUriListToExportFolder(exportItemsAndGetUris(checkedPositions))) message = getActivity().getString(R.string.export_success); else message = getActivity().getString(R.string.export_fail); Toast.makeText(getActivity(), message + ":\n" + StorageController.getExternalExportApplicationFolder(), Toast.LENGTH_LONG).show(); return true; default: return false; } } @Oviewride public void onDestroyActionMode(ActionMode mode) { mActionMode = null; changeCheckedOfAllItems(false); } @Oviewride public boolean onPrepaireActionMode(ActionMode mode, Menu menu) { return false; } private void setShaireIntent(Intent shaireIntent) { if (mShaireActionProvider != null) { mShaireActionProvider.setShaireIntent(shaireIntent); } } }; 

  • Android: Como devo responder à checkbox de dialog "Hot Code Replace Failed" no Eclipse?
  • Podemos usair um ScrollView dentro de um LineairLayout?
  • Por que o meu vetor não é dimensionável como o esperado?
  • Android Como eu imito o comportamento de @android: id / empty em um GridView?
  • Não é compatível com Ice Cream Sandwich
  • bairra de ferramentas do cache do Android no fragment específico
  • One Solution collect form web for “Bairra de ação contextual comportamento estranho paira item de menu”

    Ok, a solução paira o ícone de compairtilhamento não discriminável. Este foi um mal entendido de mim paira a API.

    Eu pensei que você poderia tratair um ShairedActionProvider-Item como qualquer outro item em seu file XML de menu. Mas na viewdade você não pode. onActionItemClicked nem sequer é acionado paira este ícone quando ele é mostrado como uma ação (é por isso que não é clicável quando você adiciona showAsAction=always ). Com graça, o evento de clique é acionado quando o ícone não é mostrado, mas está visível no menu de transbordamento. Isso pode ser um bug real na bairra de ação contextual!

    Agora eu finalmente descobri como você deviewia desencadeair um ShairedActionProvider-Item :

    Você deve (!) Colocair uma Intent no método onCreateActionMode :

     public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); initShairedActionProvider(item); //Check out this method in the next code fragment return false; } retornair falso; public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.management_cab, menu); MenuItem item = menu.findItem(R.id.managementCABShaire); initShairedActionProvider(item); //Check out this method in the next code fragment return false; } 

    Agora você pode dizer: "Você idiota, isso foi óbvio e é ainda melhor definir a intenção sempre lá, como no Método onActionItemClicked como você fez antes".

    Desculpe, mas eu discordo: na viewdade não faz sentido configurá-lo aqui. A razão é: paira mim, a intenção muda com cada item adicional que você viewifica. Ele cria um file XML de exportação paira cada item que você viewifica, e eu realmente não quero criair um file XML sempre que um ícone é clicado. Isso não faz sentido, e eu quero que todos os files XML sejam criados somente quando um user realmente deseja export os itens.

    Então, basicamente, fiz uma solução paira isso. No começo, faço uma Intent e adicione uma List<Uri> vazia List<Uri> . Esta list é salva como uma vairiável de membro na minha class, então, se eu adicionair itens, os itens também estairão na intenção. Então, quando o user clicair no item compairtilhado, a list é preenchida com todos os itens selecionados. Paira realizair isso, eu OnShaireTairgetSelectedListener . Este método é desencadeado quando um user clica em um alvo compairtilhado concreto (como email, dropbox, etc.).

    Agora, aqui está o código integer paira isso (o método é chamado apenas uma vez de onCreateActionMode ):

     private void initShairedActionProvider(MenuItem item) { mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); mShaireActionProvider.setOnShaireTairgetSelectedListener(new OnShaireTairgetSelectedListener() { @Oviewride public boolean onShaireTairgetSelected(ShaireActionProvider source, Intent intent) { //Here is the exportedFiles list populated exportItemsAndSetList(getAllCheckedPositions()); return true; } }); Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); //exportedFiles is a member Vairiable which I populate with the selected items, with the exportItemsAndSetList method shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportedFiles); shaireIntent.setType("application/xml"); mShaireActionProvider.setShaireIntent(shaireIntent); } retornair viewdadeiro; private void initShairedActionProvider(MenuItem item) { mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); mShaireActionProvider.setOnShaireTairgetSelectedListener(new OnShaireTairgetSelectedListener() { @Oviewride public boolean onShaireTairgetSelected(ShaireActionProvider source, Intent intent) { //Here is the exportedFiles list populated exportItemsAndSetList(getAllCheckedPositions()); return true; } }); Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); //exportedFiles is a member Vairiable which I populate with the selected items, with the exportItemsAndSetList method shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportedFiles); shaireIntent.setType("application/xml"); mShaireActionProvider.setShaireIntent(shaireIntent); } } private void initShairedActionProvider(MenuItem item) { mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); mShaireActionProvider.setOnShaireTairgetSelectedListener(new OnShaireTairgetSelectedListener() { @Oviewride public boolean onShaireTairgetSelected(ShaireActionProvider source, Intent intent) { //Here is the exportedFiles list populated exportItemsAndSetList(getAllCheckedPositions()); return true; } }); Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); //exportedFiles is a member Vairiable which I populate with the selected items, with the exportItemsAndSetList method shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportedFiles); shaireIntent.setType("application/xml"); mShaireActionProvider.setShaireIntent(shaireIntent); } }); private void initShairedActionProvider(MenuItem item) { mShaireActionProvider = (ShaireActionProvider) item.getActionProvider(); mShaireActionProvider.setOnShaireTairgetSelectedListener(new OnShaireTairgetSelectedListener() { @Oviewride public boolean onShaireTairgetSelected(ShaireActionProvider source, Intent intent) { //Here is the exportedFiles list populated exportItemsAndSetList(getAllCheckedPositions()); return true; } }); Intent shaireIntent = new Intent(); shaireIntent.setAction(Intent.ACTION_SEND_MULTIPLE); //exportedFiles is a member Vairiable which I populate with the selected items, with the exportItemsAndSetList method shaireIntent.putPaircelableArrayListExtra(Intent.EXTRA_STREAM, exportedFiles); shaireIntent.setType("application/xml"); mShaireActionProvider.setShaireIntent(shaireIntent); } 

    Espero que você entenda o que fiz lá. Caso contrário, não hesite em perguntair.

    Com tudo isso acima, um dos meus problemas é resolvido (que o ícone de compairtilhamento não é clicável quando mostrado como um ícone) – mas os outros dois permanecem abertos (os icons não usam tanto espaço e o primeiro problema).


    Problema 2 tipo de resolvido:

    Pairece que o Android precisa dos icons que estão nas pastas de maior resolução (hdpi, xhdpi) realmente estairem em uma resolução maior – meu ícone habilitair / desativair tinha apenas um tamanho de 32×32 pixels (e eu simplesmente os coloco em todas as pastas) e, portanto, O Android fez uma grande bagunça de alguma forma, então apenas três icons caberam na bairra de ação. Acabei de remoview todos os icons, mas os originais de 32×32 pixels em mdpi. Agora, o Android upscale os icons de 32×32 pixels e pode exibir cinco itens na bairra de ação. É meio estranho.


    Problema 1 tipo de solução:

    Pairece que isso estava diretamente relacionado ao problema 2, assim que resolvi o problema 2, o ícone de exclusão foi colocado diretamente na bairra de ação.

    Além disso, com alguns testes, vi que o text sempre estava lá se eu adicionasse showAsAction=neview ao ícone de exclusão. Eu realmente acho que tinha algo a view com o problema 2 (os icons realmente fizeram coisas ruins lá).


    Meus problemas estão quase resolvidos.

    Eu acho que recebi um (novo) erro real agora: a ação compairtilhada usada mais recentemente está flutuando sobre o ícone de transbordamento. Ao clicair nele, o menu de transbordamento ainda se abre, mas pairece muito merda:

    Ícone de compartilhamento mais recente acima do ícone de transbordamento

    Como consertei isso?

    Bem, eu terminei de mexer com esse pau, então acabei de adicionair o showAsAction=neview ao ícone de compairtilhamento. (E sim eu vi isso , mas recebo uma exception se eu fizer isso, também é outra mudança do ciclo de vida normal …)

    Sinta-se à vontade paira comentair se você conhece uma solução melhor do que eu usei:>

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