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

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);

Related

Looking for a combobox but not an Android spinner

I'm trying to get the same item as Window's combobox in Android java. I realize there's a spinner but what I need is to display a scrollable list of items that the user can simply select one or more. The spinner is nice, but it's a totally different beast.
Is there an equivalent? Because otherwise I guess I would have to create a section of text items, that I would have to build my own scroll function as well as selection. Hoping to avoid all that.
Thanks.
You're going to have to write your own, or find a library. There is no builtin equivalent. Luckily it should be easy, you basically just want a recycler view where the adapter keeps track of what items you've clicked on. That will take care of the scrolling, and the display simplifies to a normal list adapter.
Import third-party library just for little feature is unnecessary, you could try change spinnerMode to dialog, then the spinner is scrollable.
Edited:
sorry, I noticed that you need select multiple items, my answer is not suitable. You could create a custom widget.
The easiest solution is using library. There a alot library you can use for that problem. Here is the some library you can used:
https://github.com/prsidhu/MultiSelectSpinner
https://github.com/pratikbutani/MultiSelectSpinner
Or you can follow this tutorial
https://trinitytuts.com/tips/multiselect-spinner-item-in-android/
Hope it help

JavaFX 2.2 Remove Pagination's selected page label

I want to remove the Selected page label (see image below) of the Pagination control.
After digging into caspian.css I wasn't able to find any clue about how to do that. By code I also didn't find any method to remove (or eventually hide) this label.
Is there a way to do that in JavaFX without re-implementing the whole control ?
Use -fx-page-information-visible
It's described within these links:
http://docs.oracle.com/javafx/2/ui_controls/pagination.htm
https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/pagination.htm#JFXUI459
https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#pagination
I couldn't find a way either to hide just the label, but would it help to hide the whole button?
.number-button:selected{
-fx-opacity: 0;
}
That would hide the current selected button.
It's not what you actually wanted but maybe it can help you.

Making Java button dynamically?

I am new to Java and I am working on a project where depending on number of files in a directory,
buttons will be created respectively. Each button will have a customized right click context menu.
How can I achieve this or is this feasible?
I just want to know the approach to do this.
The approach that you may try:
While you iterate your directory/file list (or other process that will determine the button creation), you can generate (create an instance of) a new button (JButton), I assume you know how to use new, and put it on your form / panel.
However, most of the time, layout would become an annoying issue here.
Thus, you may try to use MigLayout to handle this.
It will help you a lot in putting your stuffs in a tidy and convenient way.
Try this approach and when you have a specific coding-part question, you can try to search the existing solution in SO (StackOverflow) or if it doesn't exist, you can ask that specific code-related question.
Hope it helps.

What is the purpose of onSearchRequested()?

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

icons of tree items in eclipse trees

Is there a way to do the following ?
I have a tree item icon which is for example :
http://cdn1.iconfinder.com/data/icons/DarkGlass_Reworked/128x128/actions/contents.png
and when a certain action occurs I want to add a flag on it ( the flag is an icon which will be place on it)
if the flag is the right mark so it should be like
http://store2.up-00.com/June12/yk105816.png
Simply, can I add image on image on an action ?
Note: I know I can do this in another way to change between the two images upon action.. but I'll have to do a loooot of work on paint of PS.
sorry for the links of images as as a new user I can't post images
What you want to achieve is called a decorator in Eclipse platform.
You can find a detailed description with example on this page: http://www.eclipse.org/articles/Article-Decorators/decorators.html
Check also the following stackoverflow question:
How to set the color of an Eclipse/RCP decorator?
How to remove a previously added decorator on a resource?
Hope this helps.
You can combine several images on the fly by using or subclassing org.eclipse.jface.resource.CompositeImageDescriptor.

Categories

Resources