Hello everyone, created a menu, added an update icon should appear there and when you press the progress bar spins, you did it before, it might have gotten tired that you ran away from the eye) The sign does not change and when you click on the menu sign, nothing happens but the markings themselves down

this is menu_main.xml:

<?xml version="1.0" encoding="utf-8"?> <menu xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android"> <item android:title="Item" android:id="@+id/action_progress_show" android:icon="@drawable/ic_refresh_white_36dp" android:showAsAction="always"/> </menu> 

this is a bar

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ProgressBar android:id="@+id/progressBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" /> </RelativeLayout> 

and this is my MainActivity:

  public class MainActivity extends AppCompatActivity { Menu mymenu; MenuItem progress_menu_item; Menu mymenu; MenuItem progress_menu_item; ... @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); mymenu = menu; progress_menu_item = mymenu.findItem(R.id.action_progress_show); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_progress_show) { progress_menu_item.setActionView(R.layout.menu_item_layout); return true; } return super.onOptionsItemSelected(item); } 

  • Perhaps this is your InstantRun buggy - Yuriy SPb
  • Is it worth checking on the device? - elik
  • Checked on Runner no problem ... something somewhere unfinished judging I will go dig deeper - elik
  • I did not understand you - on the device there are no problems? Problem solved? - JuriySPb
  • one
    Learn to format the code already - katso

1 answer 1

Solved the problem by adding a link to main_menu.xml

  xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity" 
  • one
    Those. The problem you had was not that the device / emulator does not work, but that the studio previewer did not work? If yes, then here's a tip for you - never use it - there are more problems with it than good. - Yuriy SPb
  • Yes, Yuri completely agrees with you ... Yes, just as for me, A-Studio is very sly. I’m looking for a replacement for it, don’t tell me? Can InteljDea? - elik
  • 2
    @elik, Android Studio is the most high-quality and current IDE for development for Android. - post_zeew
  • Well, I don’t argue with this, it’s just that she often has a lot of inconsistencies. Her emulators do not properly display WebView Ok, I started testing on the device - elik
  • 2
    @elik, WebView is in itself a buggy thing, and Android Studio has nothing to do with it. Instant Run is a very complicated thing, because of which sometimes something works incorrectly (but Google itself writes about these things). And about IDE - you just will not find another. Eclipse and Intellij IDEA plugins have long been unsupported. - post_zeew