i have been looking at several examples with the action bar/menu bars. but my tablet is different, at the bottom there is the back button, home, recent, three dots.....
i cannot use menu bar at the top since my app is full screen surface view that refreshes over it
i cant figure out which code is for the three dots....at the bottom left corner
http://cdn.liliputing.com/wp-content/uploads/2012/06/apps.jpg
can someone point it out pls?
The button you are seeing is the legacy menu button. It is shown for apps targeting API versions 10 and below. Specifically:
If you set either minSdkVersion or targetSdkVersion to 11 or higher,
the system will not add the legacy overflow button.
Otherwise, the system will add the legacy overflow button when running
on Android 3.0 or higher.
The only exception is that if you set minSdkVersion to 10 or lower,
set targetSdkVersion to 11, 12, or 13, and you do not use ActionBar,
the system will add the legacy overflow button when running your app
on a handset with Android 4.0 or higher.
For more information, read Say Goodbye to the Menu Button.
Without some sample code, there isn't much more we can do to help diagnose your problem.
Related
I am developing an app and using spinners(Using eclipse). I am using Fragments and also using support-v4 library. I have set MinSdkVersion to 8 for backword compativility.
The problem is, in XML, when I drag and drop spinners, it is showing me the old UI for spinner which was there in API 8 or 9 and designing UI is becoming almost impossible.
(However in my Phone, it is showing the latest UI for Spinner, but I can't design it well in XML - eclipse.)
Also attaching the URL of snapshot (as I don't have enough reputation to post and image) of the XML view within the eclipse.
Link to Image : http://tinyurl.com/ErrorInUI
I tried changing MinSdkVersion to 17. It didn't work.
In your XML Graphical editor, you can change the appearance by selecting the rendering style in the API Level dropdown (there's the current API Level number with an arrow, near the little green robot):
Is there a way to completely remove the Android options menu in XE5 Delphi? I've been testing my application on a HTC One and because my phone doesn't have a menu button and my application doesn't have an options button, android automatically adds a options menu. Since this button is added by Android there is no way to add items to the menu.
I've already tried to change the minimal SDK version, but this makes the application very unstable and makes it crash when the orientation is changed:
<uses-sdk android:minSdkVersion="14" />
Is there an other way to remove the options menu? Now there is just a large options menu in the bottom of my screen that has no menu items.
Ok, you're right in that this empty action overflow menu is added because of your lack of hardware menu button.
On a Nexus 7 it's not such an issue as the empty overflow menu is added at the end of the other soft buttons.
On a HTC One, however, you can configure the Home button to act as a menu button, which removes the action overflow button.
It's not correct to say you can't add items to the menu. My Android session at CodeRage 8 shows how to add menu items. However, I'll grant you, it's a bit of a faff.
In order to remove it, the docs say you should set the targetSdkVersion attribute (not minSdkVersion) in your Android manifest to 14 (see this blog post for details). However having tried this it causes a crash if you don't prevent rotation in the RTM version of XE5, as you saw with your tests. This issue is sat in QC, logged some weeks back, hopefully to receive a fix in the near future.
However you should consider restricting the rotation as one course of action...... This is easy enough.
you must change in manifest android:configChanges="orientation|keyboardHidden">
to:
android:configChanges="orientation|keyboardHidden|screenSize">
then you can set minsdk, maxsdk, targetsdk as you want, and application will not crash
I am currently following the tutorials on http://developer.android.com/training/index.html.
I have completed the first section and continued the second section on the same code.
In the tutorial the goal is to make an ActionBar.
I have chosen to support android 2.1 and above using the v7 appcompat library.
I assume it is installed correctly (and have followed this thread).
My question is, what is my result supposed to look like?
I have created 2 AVD's, one running API 18 and one running API 8 and am testing on my own phone (Xperia Ray running Cyanogenmod 9, which is API 15 I believe)
All 3 devices give different results.
The AVD running API 18 shows the app with an actionbar in both the main activity and a secondary activity. Pressing the logo in the Actionbar in the second activity returns to the parents activity.
The Xperia Ray phone (API 15) also shows the actionbar in both activities but does not return to the parent activity after being pressed. I suppose I still need to program that and is not standard in API 15?
The AVD running API 8 shows an actionbar in the main activity with the name of the app but shows no actionbar in the second activity.
This is the code I used, from the tutorial linked above:
public class MainActivity extends ActionBarActivity { ... }
and in the manifest in the < application > tag
android:theme="#style/Theme.AppCompat.Light"
Should this be enough to make an actionbar appear in lower versions of android or is it supposed to not show an actionbar besides the main activity in lower versions?
I'd like to fix this before continuing the tutorial.
If my question needs more clarifications, I'd be happy to provide it. All help is appreciated. Thanks!
I have no experience with AppCompat, but I recommend ActionBarSherlock appCompact, is very easy to use. Link: http://actionbarsherlock.com/
You can also customize the style with: http://jgilfelt.github.io/android-actionbarstylegenerator/
good luck ;)
I found what I did wrong.
Following the tutorial litterally, the second activity will not have an actionBar.
In each of the activities java file, the class must extend ActionbarActivity instead of Activity. (The tutorial only explicitly tells to change the main activity)
--> This makes an action bar appear in every activity.
To make the back or home button appear in all versions, I did it like this:
//Make sure we're running on HONEYCOMB or higher to use ActionBar APIs
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB && Build.VERSION.SDK_INT >= 7 ) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); //for older versions
//getSupportActionBar().setHomeButtonEnabled(true); //without arrow
}
The first if statement should already be there by default (I commented it out as it was left out some of the code examples in the tutorial. Leave it in!).
getSupportActionBar() needs to be used on older APIs (make sure the appcompat library is included correctly). Using getActionbar() on older APIs causes a Forced Close.
Using setHomeButtonEnabled() works too but is without the < icon in the action bar.
Thank you for the replies. If anyone has other suggestions or tips, they are always welcome. (are both if statements needed?)
I am trying to implement an action bar with tabs as navigation options. To do that I select the "Tabs+Swipe" option in the "New Blank Activity" section of the "New Android App" wizard as shown below.
Now, in the android manifest, when
android:targetSdkVersion="15"
which is the default value, the action bar looks like this on a Nexus 7/Nexus 7 emulator, this is the desired look of the app
Now when I change that line in the android manifest to
android:targetSdkVersion="16"
the look of the action bar changes to this
The default look remains for any version of android but 16, can anyone please explain why the look of the action bar suddenly changes when the targetSdkVersion is set to 16?
The above is reproducible in the emulator as as well as on a real nexus 7.
Full screengrabs for
Normal: http://i.stack.imgur.com/VsBA2.png
After android:targetSdkVersion="16": http://i.stack.imgur.com/OM6Y4.png
Update-10th March, 2013: Switched to the List Navigation mode (instead of Tabs) to enable move to android:targetSdkVersion=17
The reason it changes when setting targetSDK to 16 is because Google changed how tabs are measured in Jelly Bean. Specifically, look at this in android.internal.view.ActionBarPolicy:
public boolean hasEmbeddedTabs() {
final int targetSdk = mContext.getApplicationInfo().targetSdkVersion;
if (targetSdk >= Build.VERSION_CODES.JELLY_BEAN) {
return mContext.getResources().getBoolean(R.bool.action_bar_embed_tabs);
}
// The embedded tabs policy changed in Jellybean; give older apps the old policy
// so they get what they expect.
return mContext.getResources().getBoolean(R.bool.action_bar_embed_tabs_pre_jb);
}
However, I suspect you don't just want the reason, but a solution. Unfortunately, I can't give you a straightforward way to set it to only embedded.
I can suggest using ActionBarSherlock to make it consistent, though. The bonus to that is the ability to use actionbars on older devices. When using it(portrait), I can confirm that if you set the targetSDK to 16, it uses the stacked layout on Jelly Bean, Ice Cream Sandwich, GingerBread, and Froyo. At least you will be able to design your layout while knowing what to expect.
Keep in mind that in most cases, switching to landscape mode will embed them in the actionbar again, since there is "enough room" the way it measures.
I concluded the newer android tablets doesn't have a hardware Menubutton anymore.
So I was wondering if I have to insert an menu button in my own (fullscreen) app or does android offer a software included menubutton itself (even when my app runs fullscreen)?
(I don't have an android phone/tab myself to test, so I asked here)
Thanks,
Dennis
You should move away from menu buttons. It's the new style of Android applications. See this post from Android developer with the reasons to remove the button and what applications should do instead of offering a menu button.
Most of devices which are not having menu hardware button runs on android 3.0 or greater version
You just need to add one parameter as showAsAction.
Which will show menu item on action bar.
Concider reading ActionBar tutorial
Change the manifest file: you should change targetSdkVersion to <= 10.
Like this:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="9"/>