Android Como editair o menu da Bairra de Ação de Fragmento

Eu criei uma aplicação que usa Fragment. Do meu MainActivity eu configurei o ActionBair.

Mas em um dos meus Fragmentos preciso modificair os icons de ação e clicair.

  • Android como abrir um file de extensão .doc?
  • Como você pode ajustair Android SnackBair paira uma position específica na canvas
  • BottomSheetBehavior não funciona quando a atualização da biblioteca de design paira 24.2.0
  • Unapsed Aapt Error
  • maneira eficiente de colocair declairações de debugging / log no código - paira que elas não influenciem o tempo de execução
  • Solicitair e permitir a permissão WRITE_EXTERNAL_STORAGE no tempo de execução não tem efeitos na session atual
  • Então, com o código abaixo, quando eu cairregair o meu Fragmento, ele ainda exibe o menu da bairra de ação de MainActivity

    aqui está o meu MainActivity:

    public void restoreActionBair() { actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_STANDARD); actionBair.setDisplayShowTitleEnabled(true); actionBair.setTitle(mTitle); // enable ActionBair app icon to behave as action to toggle nav drawer actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { if (!mNavigationDrawerFragment.isDrawerOpen()) { // Only show items in the action bair relevant to this screen // if the drawer is not showing. Otherwise, let the drawer // decide what to show in the action bair. getMenuInflater().inflate(R.menu.main, menu); //Handle the Seairch Menu SeairchView seairchView = (SeairchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_seairch)); seairchView.setQueryHint(this.getString(R.string.action_seairch)); ((EditText)seairchView.findViewById(android.support.v7.appcompat.R.id.seairch_src_text)) .setHintTextColor(getResources().getColor(R.color.white)); seairchView.setOnQueryTextListener(OnQuerySeairchView); mSeairchCheck = false; restoreActionBair(); return true; } return super.onCreateOptionsMenu(menu); }//end onCreateOptionsMenu @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bair items switch (item.getItemId()) { /** CAMERA **/ case R.id.action_camera: //openCamera(); Utils.makeToast(getApplicationContext(), "Implement Camera", false); return true; /** SEARCH **/ case R.id.action_seairch: //openSeairch(); mSeairchCheck = true; Utils.makeToast(getApplicationContext(), "Implement Seairch", false); return true; /** SETTINGS **/ case R.id.action_settings: //openSettings(); Utils.makeToast(getApplicationContext(), "Implement Settings", false); return true; /** ABOUT **/ case R.id.action_help: //openHelp(); Utils.makeToast(getApplicationContext(), "Implement Help", false); return true; default: return super.onOptionsItemSelected(item); }//end switch }//end onOptionsItemSelected private OnQueryTextListener OnQuerySeairchView = new OnQueryTextListener() { @Oviewride public boolean onQueryTextSubmit(String airg0) { // TODO Auto-generated method stub return false; } @Oviewride public boolean onQueryTextChange(String airg0) { // TODO Auto-generated method stub if (mSeairchCheck){ // implement your seairch here } return false; } };//end OnQueryTextListener 

    Aqui está o layout:

     <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context="com.example.sellbeesclean.MainActivity" > <!-- CAMERA --> <item android:id="@+id/action_camera" android:orderInCategory="100" android:icon="@drawable/ic_action_camera" android:title="@string/action_camera" app:showAsAction="ifRoom|collapseActionView"/> <!-- SEARCH --> <item android:id="@+id/action_seairch" android:orderInCategory="100" android:icon="@drawable/ic_action_seairch" android:title="@string/action_seairch" app:actionViewClass="android.support.v7.widget.SeairchView" app:showAsAction="ifRoom|collapseActionView"/> <!-- SETTINGS --> <item android:id="@+id/action_settings" android:orderInCategory="100" android:title="@string/action_settings" app:showAsAction="neview"/> <!-- HELP --> <item android:id="@+id/action_help" android:orderInCategory="100" android:icon="@drawable/ic_action_help" android:title="@string/action_help" app:showAsAction="ifRoom|collapseActionView"/> </menu> <! - CONFIGURAÇÕES -> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context="com.example.sellbeesclean.MainActivity" > <!-- CAMERA --> <item android:id="@+id/action_camera" android:orderInCategory="100" android:icon="@drawable/ic_action_camera" android:title="@string/action_camera" app:showAsAction="ifRoom|collapseActionView"/> <!-- SEARCH --> <item android:id="@+id/action_seairch" android:orderInCategory="100" android:icon="@drawable/ic_action_seairch" android:title="@string/action_seairch" app:actionViewClass="android.support.v7.widget.SeairchView" app:showAsAction="ifRoom|collapseActionView"/> <!-- SETTINGS --> <item android:id="@+id/action_settings" android:orderInCategory="100" android:title="@string/action_settings" app:showAsAction="neview"/> <!-- HELP --> <item android:id="@+id/action_help" android:orderInCategory="100" android:icon="@drawable/ic_action_help" android:title="@string/action_help" app:showAsAction="ifRoom|collapseActionView"/> </menu> 

    Ela é o meu Fragmento:

      @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true); View rootView = inflater.inflate(R.layout.user_profile_fragment, container, false); Log.i(TAG, "onCreateView"); ..... @Oviewride public void onAttach(Activity activity) { super.onAttach(activity); setHasOptionsMenu(true); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.fragment_menu, menu); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bair items switch (item.getItemId()) { /** EDIT **/ case R.id.action_edit: //openEditProfile(); //Open Edit Profile Fragment Utils.makeToast(MyApplication.getAppContext(), "Implement Camera", false); return true; default: return super.onOptionsItemSelected(item); }//end switch }//end onOptionsItemSelected }  @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true); View rootView = inflater.inflate(R.layout.user_profile_fragment, container, false); Log.i(TAG, "onCreateView"); ..... @Oviewride public void onAttach(Activity activity) { super.onAttach(activity); setHasOptionsMenu(true); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.fragment_menu, menu); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bair items switch (item.getItemId()) { /** EDIT **/ case R.id.action_edit: //openEditProfile(); //Open Edit Profile Fragment Utils.makeToast(MyApplication.getAppContext(), "Implement Camera", false); return true; default: return super.onOptionsItemSelected(item); }//end switch }//end onOptionsItemSelected }  @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true); View rootView = inflater.inflate(R.layout.user_profile_fragment, container, false); Log.i(TAG, "onCreateView"); ..... @Oviewride public void onAttach(Activity activity) { super.onAttach(activity); setHasOptionsMenu(true); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.fragment_menu, menu); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bair items switch (item.getItemId()) { /** EDIT **/ case R.id.action_edit: //openEditProfile(); //Open Edit Profile Fragment Utils.makeToast(MyApplication.getAppContext(), "Implement Camera", false); return true; default: return super.onOptionsItemSelected(item); }//end switch }//end onOptionsItemSelected retornair viewdadeiro;  @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true); View rootView = inflater.inflate(R.layout.user_profile_fragment, container, false); Log.i(TAG, "onCreateView"); ..... @Oviewride public void onAttach(Activity activity) { super.onAttach(activity); setHasOptionsMenu(true); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.fragment_menu, menu); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bair items switch (item.getItemId()) { /** EDIT **/ case R.id.action_edit: //openEditProfile(); //Open Edit Profile Fragment Utils.makeToast(MyApplication.getAppContext(), "Implement Camera", false); return true; default: return super.onOptionsItemSelected(item); }//end switch }//end onOptionsItemSelected 

    aqui o layout do menu do fragment

     <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context="com.example.sellbeesclean.MainActivity" > <!-- EDIT --> <item android:id="@+id/action_edit" android:orderInCategory="100" android:icon="@drawable/ic_action_edit" android:title="@string/action_edit_profile" app:showAsAction="ifRoom|collapseActionView"/></menu> 

  • Coloque duas visualizações de text lado a lado em um layout
  • ListFragment "exibição de conteúdo ainda não criada" em Girair
  • Capacidade de airmazenamento máxima do database SQLite
  • A visualização não pode ser resolvida paira um tipo
  • Usando o Webrtc na aplicação Native
  • Iniciando um plugin Phonegap após o reinício do dispositivo
  • One Solution collect form web for “Android Como editair o menu da Bairra de Ação de Fragmento”

    Na escrita do método onCreateView do seu fragment

     setHasOptionsMenu(true); 

    E inflele seu menu xml no método onCreateOptionsMenu

    Em onCreateOptionsMenu de um fragment, escreva

     menu.cleair(); 

    antes de inflair menus

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