I have a number of editText's in my view and I want to be able to make some adjustments to the keypad that points up for the user when they highlight the EditText.
In particular
- Making a capitals only keypad?
- Removing the auto-correct feature?
- Adding non-english characters to the first screen of the keypad e.g. "ñ"
Is there a simple approach for changing this keypad?
In general, you don't have that much control of the on-screen keyboard that is displayed to the users. However, turning off autocorrect and making all characters capitals is a possibility, you simply need to set the android:inputType attribute in your XML. Here are the values that you can use (you can also OR | them). It would look like android:inputType="textCapCharacters|textNoSuggestions".
I wouldn't worry about the Ñ or other weird characters. Most of those are easy to get by just long pressing on a key (in this case, the N).
Related
This code makes an autocomplete and autosuggestion box for me:
if (dataAutoCompleteSearch != null) {
autoCompleteSupport = AutoCompleteSupport.install(jComboBox1, GlazedLists.eventListOf(dataAutoCompleteSearch));
}
The problem occurs when I search for names that contain UTF-8 characters that are not in the data, but start with a few words in the suggestion box.
I could not type these UTF-8 words correctly because the text was added by itself (blue highlighted).
I want to disable GlazedLists autocomplete (Auto add highlighted text when typing) because it is very difficult to type a UTF-8 character.
But I want to keep the suggestion box, looking like Google search.
No. The API of AutoCompleteSupport doesn't support this option. You'd basically have to roll your own version of AutoCompleteSupport (it's all open source) and modify it yourself to stop the auto-complete part. I've just had a quick peak at it and it's quite large and I don't have an immediate solution to offer. It'll probably require a bit of experimenting. The private AutoCompleteFilter class would be my first place to start looking at.
In this answer, I've posted my solution for disable default copy, paste, select all and clipboard behaviour for an EditText, including disable handle select cursor:
There are three steps that includes a) a short snippet of code (many times posted in Stackoverflow); b) an empty image and c) a custom and global EditText style
If one does just step a, it keeps on showing the handle select. And if one click the handle select, appears the popup with Clipboard + Select All So one should select an empty image associated with the handle select.
However, there is one feature that I can't handle at all:
The double click Android default behaviour that selects with pink background the clicked word just for a fraction of a second, below showed:
I've tried many solution proposed in StackOverflow, including change onClick (plugged by setOnClickListener) event for disable the TextEdit control for less than 1 second, using timer or post events.
I also tried handle the cursor in onTouch event.
I even try to program a empty double click handling in GestureDetector.SimpleOnGestureListener()
No success. No clue.
Update
For helping clarify, the features of my problem demand:
1) There is no way to display any extra keys to start typing
2) I need to let the user touch any point of the text, indicating their "insert" position, if applicable. Usually he types at the end of the text and there is no cursor. In that case, I disable it.
3) I need to let the user touch in sequence 2 points of the text, to make a selection, with a marked background. It's not exactly a double click, it's two comfortably separate clicks. I don't like double click for mobile.
-/-
In short, I need to work with the cursor, but not in the standard way that Android offers. Therefore I would need to disable the default Android behaviour, but without losing the cursor and the ability to select a piece of text.
-/-
There is an option to make an artificial cursor that blinks, but I imagine it is quite laborious because the cursor don't occupy on character position exactly.
Update 2
When I use in EditText global style
<item name="android:focusableInTouchMode">false</item>
The double click becomes inactive, but I cannot show the cursor anymore neither make a selection by software.
Have you tried this:
1) Have a TextView showing on the screen (non editable with non of the problems you are explaining).
2) Have a button on the screen that says "start typing" or whatever you want as UX to start the interaction. You could even put the click listener straight on the TextView.
3) Have an offscreen / hidden under another view EditText, that when the OnClick in #2 is triggered will focus on this view - thus popping up the keyboard and starting input.
4) Have a text changed listener on the edittext and whenever they type into the edittext it updates the TextView from #1 with this text.
Thus making the whole thing cursor-less.
I've found a way to work around the problem. It is not the most elegant solution that could exist, however it acceptable.
However, I don't go consider a right solution, it is just a trick. It's amazing that apparently has no general solution to turn off word selection by double click.
When I create the EditText dinamically, i set
tEdit.setHighlightColor(Color.TRANSPARENT) // tEdit is my TextEdit view
When I will select an area inside my program, I will use underline to delimit my selected area, so I keep the highlight color always transparent.
As you can see, after every text comes a tab, everything is working fine, but after third tab (see output) it generates a space not a tab.
fileWriter = new FileWriter(indexFile, true);
fileWriter.append(id).append("\t");
fileWriter.append(String.valueOf(idx)).append("\t");
fileWriter.append(String.valueOf(pageCount)).append("\t");
fileWriter.append(postal.toUpperCase()).append("\t"); <-- this one
fileWriter.append(address.toUpperCase());
fileWriter.append("\r\n");
My output:
00000347 1 1 FB-6666 DUMMY STREET 1 LAT
The problem comes after "FB-6666".
Any ideas on this?
No, it really is generating a tab - it's just that whatever you're using to view the file is deciding to handle tabs by aligning them to some boundary or other. If you make your postal value FB-6666x I suspect you'll then see a much larger space.
This isn't a problem with the file content at all.
If you want to enforce a certain number of spaces between columns, you'll need to write that many spaces. Alternatively, something else to view the file...
Tabstops don't work this way. As the wikipedia article states,
Tab stops are set manually, and pressing the tab key causes the carriage to go to the next tab stop. In text editors on a computer, the same concept is implemented simplistically with automatic, fixed tab stops.
This means the tabstop will stop at a predefined position in the textfile, not after let's say the space it would take to insert a specific amount of spaces.
It is writing a tab I promise - to convince yourself of this you should either open the resulting file in a hex editor and look at the value in that position, or add another character to the value before the tab and see how the format of the output changes.
Doing linguistics and phonetics, I often need to use certain special phonetic symbols. Although I'm using a special keyboard layout that enables me to write some of those characters by typing, they key combinations can often get both quite complex and highly repetitive, so I would like to create a litle app that would contain some buttons, perhaps, each of them capable of sending a specified (phonetic) symbol to whatever the current cursor position is, no matter what window on one's screen is in focus.
Is anything of this sort possible to do in Java?
I've seen a solution that copies the values into clipboard and then pastes them (Java paste to current cursor position), but that is not a very clean way to do it, is it? Is there a way better than just pasting the charactedr(s) via ctrl+V?
Many thanks for any help or advice in advance!
P.
You can use the AWT Robot to generate key press events. This will not provided the ability to insert arbitrary unicode characters but you can combine it with the technique you already described: transfer the unicode characters to the clipboard and generate a CTRL+V key event afterwards. You can try to save and restore the original clipboard content but this will work with types supported by Java only.
The focus problem mentioned in the comments can be solved by setting the window to not receive the focus via Window.setFocusableWindowState with an argument of false.
An alternative is to provide the unicode text via drag&drop. Most applications support dropping text in their input fields. The code for exporting the text is very similar as both, clipboard and d&d use the same interfaces in Java.
I have a large set of data from which the user has to select one. I'm thinking of a way to implement it (of course, in a GUI). I have a few ideas. But just thought of posting here as there may be better alternatives..
Say, user has to select a name from a large set of user base. If I simply put a text field for user to enter the name, then there can be issues like entering same name in different formats, misspelling etc...
I see two options here
Using a combo box
Using a list (Actually i'm thinking of something like a tool tip. As I cant show the whole list always due to space issues)
But combo box won't be much user friendly i guess. As the user will have to scroll around the whole list to select an entry. If the number of entries are too large, this will be
Which means, now I'm left only one option. A popping up list, which will change the content according the text user is entering in the text field. So he can type first few letters and the list will show all the entries starting from the entered text. Got my point, right?
Are there any other better to achieve this kind of need?
If I'm going to implement above, what will be the best way to follow. I'm thinking of extending the JTextField to add required functionality. Well, I'll put some method to set the popup list entries. And I'll add some actionListner to watch the text field, and control the popup list accordingly...
Autocomplete is what you are probably looking for. Google for "java swing jcombobox autocomplete" and limit results for the last couple of years to get relevant results. There will be a lot of examples and ideas on how to implement this with custom code.
I believe there is also some custom libraries like "swingx" that provide at least partial or full implementations to save time.
http://swingx.java.net/
They have released code as recently as the beginning of this years so it appears active and might have what you need.
You could take a look at SwingLab's autocomplete feature, it allows you to attach it to a JCombBox, JList or JTextComponent
use AutoComplete JComboBox/JTextField
based on Standard Java Classes
no issue with larger sets of data
no issue with Focus, BackSpace Key, Caret
for better performance to required sort the array before use
simple workaround for setStrict(true/false), restrict input to array