I am developing a sample for searching functionality.
I have used onSearchRequested() and on calling it, I get an edit box in which I can enter
the search parameter.
What I would like to do is, I want to capture the text entered in the edit box as I would like to send it to another activity.
Generally for an editText that is defined by us , we can access it using its 'id'.
But, since in the case of onSearchRequested(), the editText is creted automatically , so how can I access and capture the text typed in it.
Have a look at the documentation regarding creating a search interface. Part of the documentation is an example on how to set up a SearchableActivity that is called with the query entered by the user and that should do the searching and showing the results. I guess this is exactly what you want.
Related
There doesn't appear to be a specific password text dialog in the Androidx (or Android) library.
I want to add a button so that the user can switch between text view and password text view (asterisks instead of letters) for this preference even though, as someone might want to tell me, it's not a fabulous idea to store passwords as preferences. Eventually I'll have a more robust approach but in the meantime this is what I've got.
I'm using the code that Android Studio (generously) offers me for "Preference Activity". In all other respects it seems pretty good, and better than I can manage myself yet. It's just got this (annoying lack of) feature.
This question is a little too old to reference Androidx, and according to the (main) relevant answer to my context, I can't use AndroidX here. However, using the code from the Settings Activity I don't explicitly mention DialogPreference at all.
So, is there a way to slot in a "reveal" button in this situation, or should I either not use the "textPassword" input type, or completely rebuild this activity?
I was messing round with something similar the other day. I didn't use a reveal button, but just got it to never show the password:
input_password.setText(prefs.getYourPassword().toAsterix())
private fun String.toAsterix(): String {
return replace("[.]", "*")
}
With a PreferenceActivity, you would have to make a custom view. It would be an EditText and a Button. Clicking the button would set the text to either prefs.getYourPassword() or prefs.getYourPassword().toAsterix().
Once I have completed the form, I cannot see the the form's output in the ResultsLabel I created. Attached is a screenshot below, does it look OK?
All help appreciated!
Regarding your statement "I cannot see the form's output in the label", is it possible that it's hidden behind the keyboard? Press the 'Done' button to hide the keyboard when you're done typing.
Regarding your question "does it look OK":
Your first StoreValue event is saving the value as the tag, which probably isn't great practice but can work
However, your second StoreValue overwrites the first one, and the third StoreValue overwrites the second one because you're using the same tag for all three.
If you want to save the two thumbpositions for that particular name you should do this:
TinyDB.StoreValue
tag = {name.text}
value = {make a list
{cashrequired.thumbposition}
{period.thumbposition}
I'd like to develop an application that does some processing on text copied on clipboard.
I want to prevent user from copying the text, switching to my application, pasting the text and clicking on process. The process would be done instantly as the user simply copies text on clipboard. He would then go on the application to see the process done on the text copies he's made.
Is there a way to have a kind of listener on text copies on clipboard ?
Thanks
1.Use ClipboardManager.OnPrimaryClipChangedListener for triggering callback when text is copied in any app.
2.Launch your App when text copy event is triggered
3.Use ClipboardManager.getPrimaryClip () to get the copied text in your app. Use the text as you want it.
And you're done.
The way you mention sounds too intrusive. An alternate way is to parse each "keystroke" as it comes into your app. If it comes in too fast, then don't accept it on the theory that it was pasted in.
Override the long press event on the edittext field.
Check out this post on how to do it.
Is it possible to have the barcode scanner (zxing for example) called instead of the keyboard in a webview? So, just to be clear, when I tap in a text box inside my webview I'd like to override the keyboard call and have the barcode scanner open instead as an input to the text field. Is this feasible?
Yes its possible , i implemented this softkeyboard which does the job.
'Long press' shift key and you can scan a code which adds to the text field
which has focus.
http://www.androidbroadcast.com/en/softkeyboard/index.html
Barcodescanner Keyboard lets you do exactly this. It is definitely possible.
it possible go to http://www.tec-it.com/en/software/android/barcode-keyboard/barcodekeyboard-overview/Default.aspx
download barcode keyboard demo version and enjoy....
Not in any kind of standard fashion: you could plug a custom JavaScript handler that listened for focus messages from the specific text input (identified perhaps by id?) and then use the InputMethodManager to hide the input method and launch your barcode reader. When the barcode reader returns with content you could then use the same JavaScript handler to insert the result into the text input field.
This isn't exactly what you are asking for but might work: You could modify the ZXing bar code scanning library to dispatch key events for each character in the scanned bar code. I assume these key events would be interpreted by the text field. You can program the bar code scanner to append a carriage return or whatever to accept the data into the text field as if someone had hit the enter key. You could put a border around your layout and turn it red or something to indicate to the user that it will accept typed in data or a bar code scan.
It is not possible -- at least, there's nothing in Android or ZXing that lets you do this directly. But you can certainly write your own Input Method that does such a thing, if you're willing to put in the work. ZXing is open source and there have been some topics about it in the discussion group.
If I want to enforce a maximum length of input in an EditText field, I can use the maxLength attribute. But if I want to enforce a minimum length (in my case, simply non-blank), I find no corresponding minLength attribute.
I've also looked at the various 'inputType' attributes (phone, password, etc) but I don't see anything like 'required' or 'non-blank'.
I can't believe this would require a custom input filter; it's more likely the answer is so obvious it just doesn't get written down in the form I'm asking the question.
You can simply check that yourField.text() is not equivalent to null or "" at the point of submission. If it is, prompt the user to input something.
Carefull with something though. If you have a submit button, for instance, and your user presses submit without changing the focus out of your TextEdit, your method won't be called.
Take an Activity with 2 EditTexts and 1 button named "Go":
1) User writes something in EditText1
2) User clicks on EditText2
3) Instead of writting something there just clicks go.
Your onFocusChanged() method won't be called because focus is not "lost".
If you have a validation in your Go button_click method, it will trigger, of course, but you won't achieve your goal "I was looking/hoping for was a way to give instant feedback"
You can try using TextWatcher.