Turn off auto suggest of numbers for EditText? - java

Number suggestions pop up when you tap at edittext. Is there a way to receive input as number but at the same time prevent number suggestions from displaying?
I have found something similar like this. but it accepts text not numbers!
Turn off autosuggest for EditText?
below are not working since it only accepts texts and then removes suggestions.
android:inputType="textFilter"
android:inputType="textNoSuggestions"
I have tried
android:inputType="number|textNoSuggestions"
It results to accepting non-numeric symbols and does not remove suggestions either.

Android O has the feature to support Auto-filling for fields,Just only use this in your xml, It will disable autofill hints
android:importantForAutofill="no"

Related

How to set subscript and superscript text in string (such as math exponents)

I'm working on an Android app, and I need to be able to include the exponents/powers into a string (Java). I've done some searching and it seems that my scenario is making it difficult. I've looked into options such as ALT+ codes and Unicode. I'm not entirely sure if either of those, or any other options, are actually possible (I know the ALT+ codes only have '1' '2' and '3' subscripts oddly enough).
So, what's my best option, if any?
I'd like to keep it as simple as possible. I have a lot of strings to write (like math problems) and the need to subscript/superscript numbers is random. Can this be done easily?
EDIT: I suppose I was vague. My app is for studying. And the questions/answers are put into arrays and randomized each time. I'd like to be able to set the strings in the Java file as they are now
question[0].text = "solve x^2 if x=5";
But instead of the user seeing "^2", I'd like to use the actual superscripts.
ANOTHER EDIT:
global.java (class/structure that holds questions/answers)
question[0].question = "Question Text. I would like to add a superscript or two here, as if it were a math problem";
question[0].answer[0]. = "Answer 1. Add a subscript here";
question[0].answer[1]. = "Answer 2. Add another superscript here.";
question[0].answer[2]. = "Answer 3. Etc.";
question[0].answer[3]. = "Answer 4. Etc.";
Activity XML
<!--QUESTION-->
<TextView
android:id="#+id/textQuestion"/>
<!--ANSWERS-->
<Button
android:id="#+id/answerOne"
android:onClick="checkAnswer"/>
<Button
android:id="#+id/answerTwo"
android:onClick="checkAnswer"/>
<Button
android:id="#+id/answerThree"
android:onClick="checkAnswer"/>
<Button
android:id="#+id/answerFour"
android:onClick="checkAnswer"/>
Activity Java
//SET QUESTION STRING TO TEXTVIEW
textQuestion.setText(questionDatabase.getQuestion(index));
//SET ANSWER STRINGS TO BUTTONS' TEXT
buttonOne.setText(questionDatabase.getAnswer(index, 0));
buttonTwo.setText(questionDatabase.getAnswer(index, 1));
buttonThree.setText(questionDatabase.getAnswer(index, 2));
buttonFour.setText(questionDatabase.getAnswer(index, 3));
"NEXT" and "PREVIOUS" buttons allow the user to move through the questions by incrementing/decrementing the "index".
So, because of this, the activity never knows (I don't think) which questions/answers need text to be superscript, and why I'd like to be able to set the questions/answers sub/superscript myself when I enter the questions/answers into the array. Can this be done?
EDIT: #jared burrows was very helpful in chat and has helped me almost reach the end of my issue. I'm now able to use setText(Html.fromHtml()); on my textview (question text) and it shows the subscript and superscript properly. But on my buttons (answers) I tried to employ the same tactic and it doesn't work the same. "X2" just becomes "X2". Why is this? Why don't my buttons accept the html just like the textview.
Superscript:
textView.setText(Html.fromHtml("X<sup>2</sup>"));
Subscript:
textView.setText(Html.fromHtml("X<sub>2</sub>"));
References:
Subscript and Superscript a String in Android
http://www.w3schools.com/tags/tag_sub.asp
http://www.w3schools.com/tags/tag_sup.asp
The answer to this was a combination of help from #Jared Burrows and AlanV. So thank you to you both.
view.setText(Html.fromHtml(stringGoesHere));
This does work, but out of the box it doesn't work for buttons due to some frustrating feature in (I think) Android 5.0. Buttons are automatically set to all caps, and because of this, it overrides the html formatting.
So, to allow buttons the ability to use html properly, you must set the attribute to false.
<button
android:textAllCaps="false";/>
Thanks again to Jared Burrows and AlanV.

EditText Keyboard Inputtype issue

Which EditText Keyboard Inputtype combinaison can help me getting the following view. I try several issue but nothing. May be someone among you does already face this problem.
What i want to get is Numerics on the top and the possibility to switch to symbols and letters
What i want to get if a use touch the EditText must be as following
You may add the following attribute to your EditText in xml.
android:inputType="text|number"
However, some of the characters you input will not be appear - those which conflict with type number, like # = ! etc.
And in order to get search button (on bottom-right) in your virtual-keyboard, you may use:
android:imeOptions="actionSearch"
Update
Add the following to your EditText's xml and it will get you all the characters available in the keyboard under number inputmode:
android:inputType="number"
android:digits="0123456789.##$&*-=()!"':;/?"
If you want to support more characters then simply append their html name in android:digits.
Try this:
<EditText
android:layout_width="150dp"
android:layout_height="150dp"
android:inputType="PutHereNestedInputType"
/>
InputTypes
Hope it's help.

Manual keypads shown to user when an editText is highlighted

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

Android inputType="numberDecimal" brings up keyboard without commas

So i have been playing around with a little game with some mathematical questions. The application gives you, for example, a question like 23 + 47, and that's fine and all, but when it gives you a question like 9/6 the problems appears. Since you input the result in an EditText, i need the correct input type. But! when i do
android:inputType="numberDecimal"
the soft keyboard it comes up with, is a soft keyboard without seperators, which mean i can't make commas. And it pretty much ruins the game :-)
I have tried things like
android:inputType"numberSigned|numberDecimal"
i have also tried
android:digits="0123456789."
but nothing worked so far.
I just can't get the right keyboard up.
Any suggestions?
Try add comma ",". It may cause from different format of digits.
<EditText
android:inputType="number"
android:digits="0123456789.," />
android:inputType="numberDecimal"
is for taking decimal inputs, so all the digits from 0 to 9 including the decimal point sign(.) only can be the input values. And it works fine. I don't understand where comma sign came into picture.

Customized keypad for a calculator application

I've seen lots and lots of questions about selecting the best input Type keypad for edit texts, yet I couldn't find the one that helps me out with a semi calculator app.
I have tried decimal, phone, number flag signed and their combination but it doesn't give me what I am looking for.
Is there any input type including numbers, (+), (-) and (.) ?
Or how can I create and use this keypad if I have to?
Have you tried this, it seems to have what you want:
<EditText
...
android:inputType="number"
/>
Aside from numbers and basic operators, it includes the underscore. It even has modulo (%), factorial (!), confusion (?) should you decide to get fancy...
Addition
This is probably closer to what you want, since you apparently aren't looking for an underscore...
<EditText
...
android:inputType="phone"
/>
I only know of the three basic keyboards include in Android. If the "phone" keyboard isn't an acceptable option, you probably have to design your own...
The way I would approach designing a keyboard is like any other app. For this I would use an EditText above a TableLayout to help you organize your grid of buttons. And simply each button click would add the corresponding value to your EditText.
Addition
To clarify, a "phone" keyboard on an HTC:

Categories