ActionBarSherlock - Action Items in menu overlapped by 'three dots button' - actionbarsherlock

Today, I'm fighting a pretty ugly bug.
I want to put some items into bottom menu (not using tabs), but I want that these items only have defined "Title" and not "Icon". Everything works on devices with Android <= ICS. Widths of menu items are calculated correctly (I'd like to use "always" attribute for first three items, others use "ifRoom").
When I start the app on JB device, the last of these menu items is overlaped by "three dots button" hiding other four menu items.
I've tested this on HW Ascend G300 (ICS, hw menu button disabled), where the result was correct. On HTC X (JB), the result was incorrect.
Ps: when I set icon of first menu item (action_menu_map), everything works (I don't want to set it, of course).
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/action_menu_map"
android:showAsAction="always"
android:title="#string/ab_map"/>
<item
android:id="#+id/action_menu_list"
android:title="#string/ab_list"
android:showAsAction="always"/>
<item
android:id="#+id/action_menu_routes"
android:title="#string/ab_routes"
android:showAsAction="always"/>
<item
android:id="#+id/action_menu_call"
android:title="#string/ab_call"
android:icon="#drawable/call_icon"
android:showAsAction="ifRoom"/>
<item
android:id="#+id/action_menu_report_event"
android:title="#string/ab_report_event"
android:icon="#drawable/message_icon"
android:showAsAction="ifRoom"/>
<item
android:id="#+id/action_menu_settings"
android:title="#string/ab_settings"
android:showAsAction="ifRoom"/>
<item
android:id="#+id/action_menu_info"
android:title="#string/ab_info"
android:showAsAction="ifRoom"/>
</menu>
Thanks ;)

I had this three dots problem appearing at the bottom and it was only appearing at the bottom of HTC devices only (Sorry, I might be wrong about this but this is what I found). So, at last I changed the Project Build Target with the API level of 18 or I set android:targetSdkVersion="18" in my manifest file and the three buttons disappeared.

Use this
SHOW_AS_ACTION_IF_ROOM
Using this, if your actionbar does not have enough space to keep more items then it would go inside vertical 3 dots.
e.g.
menu.add("More").setOnMenuItemClickListener(this.DebugButtonHandler)
.setIcon(R.drawable.info).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

Related

Side menu with the search button on the Roku channel's home screen

I'm developing a Roku application with SceneGraph and I would like to have a side menu with the search and other buttons on the channel's home screen.
I couldn't find how to implement this. Is it possible?
Thanks a lot
Yes it is possible by doing custom design. Left menu can be done using LabelList, proper tanslation should be given for other components in order to avoid overlapping of UI.
I have already done in 3 channels, so it's easy to keep if you have clear idea about the element placing.
Eg:
<Rectangle color="0x000000" width="230" height="440" translation="[-10,0]" >
<LabelList id = "categoriesLabelList" translation="[5,20]" textHorizAlign="left" itemSize="[200,40]">
</LabelList>
</Rectangle>
You can also hide the left menu when the indicator focus any other elements like RowList, MarkupList, Postergrid or any element. Showing and hiding should be handled in onkeyevent
function onKeyEvent(key as String, press as Boolean) as Boolean
end function

Can't remove padding from Activity Dialog

I have an activity styled as a popup:
[Activity(Theme="#android:style/Theme.Dialog")]
public class GameOverPopup : Activity
But I'm always stuck with a white padding around my controls (ignore the black border, it's not part of the popup):
I've tried setting the padding, margin, etc. to 0dp but always have that extra space.
How can I remove it?
UPDATE:
So I've tried the following according to suggestions:
In Styles.xml:
<style name="PopupDialog" parent="android:style/Theme.Dialog">
<item name="android:padding">0dp</item>
</style>
And then in my Activity (in the OnCreate Override):
SetTheme(Resource.Style.PopupDialog);
Yet I still have the padding :(
As I recall, the auto-generated activities in Eclipse include the Android activity-wide margins by default. You might check to make sure you have removed these lines in your XML layout if you used the default template.
EDIT, to sum up some comments and avoid creating a discussion: it appears that the problem may be due to the default padding in the dialog box style. Try creating a style with that style as its parent, and manually set the padding/margins as needed: http://developer.android.com/guide/topics/ui/themes.html#DefiningStyles.
Got it!!
Problem is that I set the theme in code on the OnCreate AS WELL as an attribute to the activity. So I remove the code from OnCreate and put the following attribute in my popup Activity class:
[Activity(Theme = "#style/PopupDialog")]
public class GameOverPopup : Activity
And my Styles.xml is:
<style name="PopupDialog" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">#null</item>
<item name="android:padding">0dp</item>
</style>

Using appcompat support library, Overflow not working on API 7?

I am using v7 appcompat support library. The action items work showing in the actionBar just fine on either newer or older devices.
However, I don't get Overflow on API 7. For example:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:appcompat="http://schemas.android.com/apk/res-auto" >
<item
android:id="#+id/menuAction"
android:icon="#android:drawable/ic_menu_directions"
android:title="#string/barButtonTitle"
appcompat:showAsAction="always|withText"/>
<item
android:id="#+id/menuAction1"
android:title="#android:string/untitled"
appcompat:showAsAction="never"/>
</menu>
appcompat:showAsAction="always|withText" works, it shows as an Action Item in ActionBar. However, appcompat:showAsAction="never" doesn't show in the Overflown as it does in newer platform. It is hidden on the bottom, and revealed when you pressed on the older menu button.
Is that the intended behavior from appcompat support library? or am I missing anything to get the Overflow working on the older platform?
Is that the intended behavior from appcompat support library?
Yes, it is
The overflow button (3 dots) is only shown if the devices don't have a hardware menu button.
Every gingerbread-device must have a menu-button, so the overflow button won´t show on API level 7
For more information about this topic, the following blog-post might be interesting:
http://android-developers.blogspot.de/2012/01/say-goodbye-to-menu-button.html
The overflow do not show in older versions as far as I have researched, but you can use in your manifest (inside the activity level) the following (for pre ICS):
<activity ...>
<meta-data android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
</activity>
this will show the action itens at the bottom of the display, you have to add this in all activities you want to have this behavior. For ICS > you can add the following in the manifest at the application level, this will have effect in all activities.
<application android:uiOptions="splitActionBarWhenNarrow">
</application>

Android UI Best Practices for Display Field turning into Input Field

I'm programming an android app with a list displaying images and some additional information like title, place, etc...
I'm new to the android ecosystem and wondering what are the best practices to implement a list element which normally displays the mentioned information and turns into input fields on a press on the listelement.
Do I have to draw the display elements (e.g. TextField) and the edit element on top of each other and set visible for either display or input? How to handle this generally? Or do I replace the layout responsible for the list element altogether?
I know that for the simple case of a text there is a simple solution for making the EditText field look like an uneditable TextField. I'm, however, looking for a general answer covering broader cases than just a TextField.
Thanks!
you can make the elements of the listview a view flipper having two views.one you textview and other and edittext.
<ViewFlipper
...
<TextView
... />
<EditText
... />
/ViewFlipper>
Then in the onItemClickListener of the list items you can call flipper.showNext();
So, flipper works like, it shows only the first view defined in it and on the subsequent call of showNext() it displays the next view defined in it.
So if you have 2 elements in it, it will behave as the coin with two sides.
So in your situation there are a few ways you can achieve this.
First way is to build a layout which contains TextView and EditText and in first initialization your edit text won't be visible. And in your OnItemClick you have to hide your textview and show editext with value of your current data and option to edit.
The second way which I think is more user friendly is that you can show an AlertDialog after OnItemClick with custom layout where you can change the values and update the listview after user press Yes or do nothing is he selects No.
It depends on you which way you will do that, but I think the second option is the better one.

Android - tablet to phone screensize

I have an app that has a screen like this (on a 10" tablet) :
Now I need to amend the app to also work on a phone. As the screens will be smaller, I want to take the "split view" UI and change it so that the left hand side list view is shown on its own, then on selecting a row the appropriate right hand side list view is then shown.
How do I handle this in the app, as one activity currently handles both listviews, and I guess the phone will need two one for each listview.
How do I detect which one to do?
thanks
See Supporting Different Screen Sizes.
Typically this is done using Fragments, but the basic idea is the same whether you use fragments or not. You create two different layouts for your Activity depending on the screen size.
Save the default layout single-pane for phones at res/layout/activity_main.xml
Save the dual-pane tablet layout at res/layout/activity_main_twopane.xml
Then you use layout alias files with the screen size qualifiers described in the link to determine when the tablet layout should be used. For example to show the dual-pane layout on large screens and on screens with at least 600dp in the widest direction (includes large screen phones such as the Galaxy S3), you could do this:
res/values-large/layout.xml contains:
<resources>
<item name="activity_main" type="layout">#layout/activity_main_twopane</item>
<bool name="twopane">true</bool>
</resources>
res/values-sw600dp/layout.xml contains:
<resources>
<item name="activity_main" type="layout">#layout/activity_main_twopane</item>
<bool name="twopane">true</bool>
</resources>
The Android system will take care of loading the proper layout file (either res/layout/activity_main.xml or res/layout/activity_main_twopane.xml) when your Activity loads the layout:
setContentView(R.layout.activity_main);
Just remember that the views that don't exist in the single-pane layout will be null when you try to access them (e.g., there won't be two ListViews anymore). Checking whether a certain View exists is one way to detect which layout you are using.
Also note the use of optional Boolean resources in XML files. This is a handy way to pass the "is it a large screen or small screen" variable to your Java code. You can access Boolean resources in your Activity like this:
boolean isTwoPane = getResources().getBoolean(R.bool.twopane);
You should have a look at the MasterDetailedFlow Navigation template. Eclipse:NewProject>check create Activity>select "MasterDetailedFlow" Navigatoin type. Have a look at Data Binding on Android

Resources