Using SherlockActionBar I wrote a custom actionProviderClass (a spinner) for one of the action bar items.
I decided I don't need it and deleted all the files for it as well as the actionProviderClass attribute in the menu file. I even removed the spinner's values from strings.xml.
However, if I switch to horizontal orientation, the damn thing still shows up. I tried a fresh emulator as well as a device and it still happens. I also cleaned the project in Eclipse.
I guess something is being cached somewhere, anyone have any ideas?
User error here.
SherlockActionBar will collapse tabs into a spinner sometimes even though there is space for views
Related
I'm new to Android Studio and I am trying to create a note app. However, I can't seem to interact with my action bar at all.
I am using the latest version of Android Studio. I was looking some tutorials of Android Studio, videos of one year ago, and in the videos, the app emulator showed 3 dots (the settings icon) on the top-right corner of the action bar. However, mine doesn't create it. It doesn't create any menu icon. In fact, I do NOT have a menu sub-folder on my RES folder, and my MainActivity.java does NOT have the onCreateOptionsMenu and onOptionsItemSelected methods that should be created by default.
Any way I can fix this? How can I add a simple icon my action bar?
Thank you
You can add these methods manually by clicking CTRL+O (shortcut for override methods) and choose these two methods from the list.
You can also write them from scratch or copy-paste them from somewhere.
EDIT:
Try all the different templates in the New Project menu. Maybe some of them works for you. And good luck. This appears to be some weird bug.
I'm a new to Android development and I've been giving Android Studio a spin. I've followed Google's tutorial and I still haven't been able to get the ActionBar up and running either on the emulator or on the real device. I've specified the min version in the manifest file and I've also edited the menu and activity xml files accordingly.
Confusingly, the UIs shown in the activity_foo.xml and menu_foo.xml are different:
activity_foo.xml:
menu_foo.xml:
Even more confusingly, the final app when built shows both the Search and Settings in the hamburger menu though I do not recall seeing it in the GUI previews:
How can I fix this?
Confusingly, the UIs shown in the activity_foo.xml and menu_foo.xml are different
They are supposed to be different. One is showing you a layout file. The other is showing you a menu resource. Their previews are not supposed to necessarily match. After all, an Android app that is bigger than a breadbox will have many layout resources, few of which will be defining the contents of an activity.
For those layouts that do define the contents of an activity, IIRC, you can have the same tools:context=".FooActivity" in the root element of your layout file, and the preview may take that into account.
Even more confusingly, the final app when built shows both the Search and Settings in the hamburger menu though I do not recall seeing it in the GUI previews:
In the preview, the search item is represented by a toolbar-style button (icon is a magnifying glass).
In your menu resource, you have one <item> that has android:showAsAction and one <item> that has app:showAsAction. Either you are using the appcompat-v7 action bar backport, or you are not. That would be determined by things like:
what Java class your activity inherits from (ActionBarActivity or AppCompatActivity for appcompat-v7)
what theme you are using for the activity in your manifest (if it is based on Theme.AppCompat.*, you are using appcompat-v7)
If you are using appcompat-v7, you need to change the android:showAsAction to app:showAsAction. Given the results of your run of the project in the emulator, my guess is that you are using appcompat-v7. If you make the change to the menu resource and run the project again, you may see the search item show up as the magnifying glass icon, as you see in the preview. I say "may" because there may or may not be room to show that toolbar-style icon, depending on screen size and orientation of the device that runs your app — action bar items with ifRoom will show as toolbar-style buttons if there is room or will fall into the overflow menu if not.
My Eclipse/ADT is running into a problem in which the menu items would not show themselves under the layout tab and I am also unable to add any new item using the Add option. The normal XML view however is working just fine. Has anyone faced the same situation before?
Try restarting Eclipse and or your computer, that usually fixes any problems.
I have made several apps before using eclipse. I (think) always started out with file>new>project>application project and eclipse set up a project in which the main activity was comprised of a black screen with nothing in it - until I used the "graphical layout" editor to start adding some buttons/text etc.
But in more recent versions of eclipse it appears that however hard I try, I always seem to ens up with some components already on my activities screen. It appears that some "style" or "theme" (whatever they are) has been selected in the process and my activity starts with a fat bar across the top with my application's icon on the left of it. I have attempted to make edits to various xml files to remove the unwanted icon/bar, but so far to no avail.
What do I need to do to get a properly blank application so that I can be fully in charge of every pixel on the screen?
In your graphical layout preview select AppTheme select theme select Theme.NoTitleBar.FullScreen
You should see a preview with no title bar
Add this in manifest for your activity
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
How do I remove the android emulator's Status Bar inside Eclipse's Graphical Layout? My application is set to run in full screen mode, but I'm having a hard time in layouting because the status bar is present in the graphical layout of Eclipse.
You can just change the theme in the drop-down list (or perhaps better said in Android terminology: Spinner :)) at the top right corner in the layout editor to one of the *.NoTitleBar.Fullscreen options.
Edit: added screenshot.
By the way, if you have a hard time creating layouts that properly scale with or without the titlebar/actionbar, you may have to rethink if you're going down the right path. If you're developing for a specific (number of) device(s), then I haven't said anything.
you can select the theme spinner and select the "Theme.NoTitleBar.Fullscreen".
Using code:-
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
above written code placed in oncreate method
I had the same problem. In debugging process, my graphical layout was perfect on the Eclipse but not correct on my phisycal device because of the statu bar at the bottom of the graphical layout on Eclipse.
I resolved this problem modifying the Theme of the layout inside eclipe and choosing "SearchBar", as shown in the pictures below. I hope to solve this question.
See the setting on Eclipse