Android: always show menu bar/static menu bar - android-layout

I would like to use the menu bar instead of a tab bar (tabs are not made for being at the bottom of the view ...).
Is there any chance to give the menu bar a static behaviour?
Related post:
android : set the menu out / visible with the solution:
new Handler().postDelayed(new Runnable() { public void run() { openOptionsMenu(); } }, 2000);
It works fine, but hides away constantly.
Many thankx!

It sounds like you're trying to abuse menu functionalities. What could be the solution: create a vertical LinearLayout with two additional layouts inside. Let the top one have layout_weight="1" and here place your content. In the bottom one place images or buttons or similar, which you could make look like tab options or whatever you want.

Related

webview.findnext() start highlighting from the current position of touch in the screen

I'm new in android studio. I'm working on a simple project. It uses a webview which loads the html page. I also use an action bar for searching, refreshing , ... in the page bellow:
By pressing the search button, findAllAsync() method is used to find and highlight all the matches in the page (matches are shown in yellow color). The next button in the action bar uses the findnext(true) method and allows user to move between the highlighted matches. Using this method, the next one is highlighted in red color:
next.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
st = et.getText().toString();
if(!st.equals("")&& st!=null) {
ourBrow.findNext(true);
}//not null
}//on click
});// next Button click
If I only scroll or zoom in the webview everything is ok and the find next is continued from the previous one in the page. However if i touch somewhere in the webview and then click the next button, the red highlighting is not continued from the previous position in the page. For example if the previous red highlighted is at the first of the page and i touch the end of the page and when i click the next button, the middle yellow matches are escaped and the last one which is in end of the page is highlighted in red color and red highlighting is continued from this position.
Since i need the user can continue search from the previous position and touching the screen does not affect this order, i searched a lot. I tried to disable touch event of the webview but keeping zoom and scroll ability based on the Android disable WebView touch but keep zooming/scrolling. But my problem is still unsolved. Please kindly help me to solve this problem.
thanks.
Edit:
To solve this problem i tried to clear focus of the view(How to remove focus without setting focus to another control?). But it doesn't work:
View current = getCurrentFocus();
if (current != null) current.clearFocus();
ourBrow.findNext(true);
I would recommend the following not the best approach (and it depend on your web page) but it will work, render the content of your web page to html using :
webview.loadData(URLEncoder.encode(result).replaceAll("\\+", " "), "text/html", Encoding.UTF_8.toString());
Than do whatever you want with your text highlight the way you want and then render it back to web page like this:
myTextView.setText(Html.fromHtml("Your HTML Page"));
API after nugget:
myTextView.setText(Html.fromHtml("Your HTML Page", Html.FROM_HTML_MODE_COMPACT));
Hope it helps

How to make an expandable window or dialog in FLTK?

I want an 'expandable' window/widget.When clicking a button on the current window, another widget will shows up, which is attached to the current window, and it can be 'fold' back if clicking the button again.
It is not a pop-up window which is free to move with respect to the main window. I want it to be attached to the main window. Anyone has any idea? Thanks a lot.
I tried making a large window consisting of two box, with one being tackled to show or hide, but the window size does not change. If you resize the window, then the position does not look right.
Have you had a look at http://seriss.com/people/erco/fltk/ and the test programs that come with the fltk distribution?
Basically you need to set one resizable widget for the window/dialog. Make this the group that you are showing/hiding when you press the button.
If you have an FLTK distribution, have a look at the program test/resize.cxx as an example of how to do resizing based on button clicks.
I'm not sure I understand what your exact problem is...
Perhaps you need a widget that's not always shown on your main Fl_Window.
Then pressing another button makes it visible and attached somewhere in
the window, according to the window's size...
And when you resize the window, it changes its position, so it is always located,
let's say, at the bottom right of it. If I have understood your problem correctly,
then make a class, myWindow or whatever, a subclass of Fl_Window.
And override the resize function, which is called when the window is being resized.
class myWindow:public Fl_Window{
Fl_Button *mySpecialWidget; //the movable widget (not allways a button ofc)
public:
myWindow(int x, int y, int w, int h, const char *L=NULL):
Fl_Window(x,y,w,h,L){
mySpecialWidget = new Fl_Button(.....); //initialize subwidget here
add(mySpecialWidget); //add it as a subwidget of myWindow
//may also include all the other needed widgets here...
}
void resize(int x, int y, int w, int h){
//override this Fl_Window function, with
//any extra functionality that you need
//example, check window size-> set relevant position for mySpecialWidget
}
}

ExtJS 4: Prevent Ext.grid.Panel header menu from closing after clicking "Columns" sub menu

The Sencha ExtJS framework Ext.grid.Panel component is great for representing result set data. However, it gets rather annoying for end-users when they try to enable and disable the columns in the grid. When you click the right side of a column header, a down arrow appears indicating there's a menu. When you click that arrow, a menu drops down. In any other HTML application based menu (or desktop app menu), you can either hover over a [sub] menu option or click the [sub] menu option and the next sub menu pops out. In the case of the Ext.grid.Panel, when you click a menu option on the main header menu hoping to expand the nested sub-menu, the entire root (column header) menu disappears. This would be represented as an enhancement by Sencha since there is a workaround--that being don't click on the menu option "Columns". It still works if you don't click, but it's just not intuitive. Who is bright enough to fix this in the extjs 4 framework code?
According to source files in the documentation this behavior is fixed in 4.1.2 (which is not available yet for public).
But!
Ext.define('MenuFix', {
override: 'Ext.menu.Item',
onClick: function () {
return this.menu ? null : this.callParent(arguments);
}
});

Menu items are not shown in SherlockFragmentActivity with tabs

My application runs on Gingerbread. It can properly show action-bar menu-item in normal SherlockFragmentActivity but when I add a menu item in an Activity with tabs the item is not shown. I was expecting to see the item above the tabs on the right of the name.
Is that normal or I'm doing something wrong?
I can add normal options-menu item that are properly show in the menu.
So the main question is: did someone manage to show both the tabs and the action-bar?
You're doing something wrong. Including other menu options doesn't have any issue. If you're using the actionbar spinner, then it's a different case as that wont work with tabs.
try adding the item in PrepareOptionsMenu in place of CreateOptionsMenu
I hope this will work

Altering the YUI menu's mousing behavior

I'm using Yui to build a "popup" menu that works a bit differently with the mouse than usual. This is not a ContextMenu, because I want it to respond to left clicks, and the ContextMenu seems bent on responding to right clicks.
Following the examples, if I do this, the menu comes up and everything is close to how I want it:
YAHOO.util.Event.addListener(myClickTarget, 'click', myThingGotClicked);
In my myThingGotClicked function, I manually set the menu's position and show() it.
My problem is that I want to "bind" the menu visibility to the state of the mouse button. That is, on a mouseDown, I want the menu to come up, and on a mouseUp, I want the menu to disappear (selecting the active item, if any). So, listening to the 'click' event doesn't do the right thing, because a "click" is only sent after mouseUp.
The "obvious" solution is to do this:
YAHOO.util.Event.addListener(myClickTarget, 'mousedown', myThingGotClicked);
But this doesn't work. Stepping through in a debugger, you can see that it does actually bring up the menu on a mousedown, but then something immediately hides the menu. At full speed, it looks like nothing happens at all.
Any thoughts?
The problem is that the MenuManager class listens for the mousedown event at the document level and hides all visible Menu instances. So, since you are building a unique sort of Menu implementation, you'll need to stop the propagation of the mousedown event inside your handler so that the MenuManager doesn't handle the event. Here is some pseudo code for you:
var myThingGotClicked = function (event) {
YAHOO.util.Event.stopPropagation(event);
// Do other stuff
};
YAHOO.util.Event.on(myClickTarget, 'mousedown', myThingGotClicked);
Todd
That's a bit closer, as the menu does pop up, but if you try to make a selection in the menu, the text selection of the page underneath goes sort of nuts. I also need to add a mouseup handler, I think, as the menu doesn't go down on mouse release.
What I really want here are menus that work like menus on every version of the Mac OS (until more recently when OS X added the "click to make the menu 'sticky' to the default behavior).

Resources