What is the purpose of onSearchRequested()? - java

What is the purpose of onSearchRequested()? I am referring to here: http://developer.android.com/reference/android/app/Activity.html#onSearchRequested%28%29
The following is stated: "You can override this function to force global search, e.g. in response to a dedicated search key, or to block search entirely (by simply returning false)." Specifically, what does the bolded piece mean? Does it not mean that we are able to disable this button? I just had a heated discussion at: Android - How to disable Search button, how to implement onSearchRequested()?
As you can see, Phil is suggesting that I have to go the other route. My questions are: can JUST this function be used to disable the search button completely? Can just this function be used without having to disable this button from the dialog builder? What did google meant with the above quoted statement? Thank you for your time.

You should be able to disable the search button using it, i would think google mean that you can block someone trying to search from within your app( IE skipping a progress dialog)
but since most android phones don't come with search buttons anymore, its not a very used function.
and yes you should be able to disable it on the fly without going through the dialog builder.
Swift

Related

How to build a growing form in android

My idea is to create a kind of growing form. Now the question is: What is the best way to do this? I haven't found a library, yet. On the picture below, you can see how I thought it to be. It should go to the next step after each input and an EditText field should appear. Any advice on existing libraries or tips on which UI component should be used to realized would be appreciated. Thanks for the help!
you have plenty approach but the one i prefer to use:
make your list, then for each index assign its next EditText. by default make your all EditTexts (except first one) disabled. then add a listener each index to observe its text. as soon as it was filled tell that listener to enable its next EditText.
maybe its not so efficient but its simple and makes code more readable. and also you can extend that easily if you just implement two first indexes because the rest is just the same.

how to limit the reorder in draglinearlayout (need some idea!)

i want to use draglinearlayout to do drag and drop action. See the link in Github https://github.com/justasm/DragLinearLayout
This source library allow user to drag those view added by the AddDragView(View,(View) findViewById(R.id.controller)).
In my draglinearlayout, i have various views (cannot drag) and many dragView. i want to limit the drag action across the normal view(cannot be drag). That mean if i try to drag the dragView across those normal view, it should detect it and stop my action.
Do I need to override which part of the source codes??
I have search for google using keyword 'draglinearlayout', but there are only few of relevant website and i cannot found what i want!!!
I guess the easiest way is to remove your elements non-draggable from the DragLinearLayout and put it in a separate LinearLayout. I honestly don't think it is possible otherwhise.
Also you can't override some parts of the code ( like the ontouch events ) otherwhise it will cancel the draglinearlayout effect.
If you can't find what you want you can also open a new issue on the related github.
Because of addDragView(...) is actually addView(...) followed by setViewDraggable(...)
Try to use
layout.addView(view);
layout.setViewDraggable(view, view); // only if you want it dragable
instead of
layout.addDragView(imageView, imageView);

Disable key-pressing in MessageDialog

I have a problem with my software developped in Java. The user has to write a text in a JtextPane. When there's no time left for him to write, a pop-up appears.
The only problem is : if the user is writting when the message pops up, the pop-up disappears because the key pressed validate the message.
Is there's anyway I can disable this fonction ?
I use this to create the MessageDialog :
JOptionPane.showMessageDialog(null,
new UTIL_LireFichierTXT().getText(MessageTempsImparti)
,new UTIL_LireFichierTXT().getText(MessageAttention),JOptionPane.WARNING_MESSAGE);
Thanks for reading.
Disabling normal application behaviour (such as manipulation of dialogs with keys) is not a great idea. It confuses a lot of users, who have been groomed to expect certain core functionality in GUIs, plus it can prove a real problem for users with disabilities, who may need to use keyboard navigation in place of a mouse.
I would suggest you consider a different method of telling the user the time is up. Perhaps a banner label appearing on the application somewhere?

Get number of +1's for url in android with PlusClient

So I'm trying to implement a custom +1 button in an android app.
I have the standard PlusOneButton working - it shows the number of +1's but I can't read the number from it. And the PlusClient doesn't seem to have the ability to tell me the number. I tried Google+ REST API but it doesn't have this functionality either.
I know there's some hack that could get the number over a POST call but that already stopped working once and I can't rely on non-official stuff.
So: is there any way to get this number through the standard google-play-services.jar?
Also: is there a way to activate a hidden PlusOneButton when the user clicks my custom button? .performClick() doesn't work.
Thanks.

Working in java image

I will explain my question clearly.
I need to zoom in/zoom out the world map.
When I click on the particular country in map, control should redirected to new page with respective the country.
I dont have any idea about this in java. Please explain the steps to acheive the above task.
As the question is quite general, here is a general answer: Zooming often means, that you want to display a certain percentage of somethin, and not the whole, where your size of the displayed will not change.
But in your case it seems more like a "find a mouse click in a polygon" thing. So you have to add a selection/click listener to whatever widgets you use (Swt? swing? ....?) where you change what your program renders.
It sounds like you may be trying to reinvent the wheel. Google etc have already solved this problem rather well. It might be better to incorporate an existing solution into your application. Have a look at GoogleEarth inside Java Swing.

Categories

Resources