how is it possible to implement a native autocompletetextview for react native with java?
how come you don't have any?
You can make you custom component for the same, by calling the api on changetext of text input and on modal you have a flatlist to render the response for the same. But then in this case you have to cancel the fetch call of the previous state if user enters the text very fast otherwise you will end up calling the server many times.
Alternatively you can use the libaries below:
1. http://github.com/mrlaessig/react-native-autocomplete-input
2. https://github.com/maxkordiyak/react-native-dropdown-autocomplete
I hope this helps...Thanks :)
Related
I have 2 buttons first button has this id id="#+id/button_A" and second button has this id id="#+id/button_B"
button_A I named it text="areNotificationsEnabled ( On )"
button_B I named it text="canDrawOverlays ( Off )"
I want when the user block or unblock app notification, So update button_A to On or Off. Same thing with button_B.
I can solve the problem using onResume but there is exceptions like the user can block notification from status bar without leave the app or using split screen to turn on or off canDrawOverlays
I solved the problem using CountDownTimer and make check every 250 milliseconds but I think it's not good way to do that, What about onWindowFocusChanged or there is better way?
As far as i know this is not possible in the traditional view system.
However, it is possible with Jetpack Compose, Accompanist & some experimental api - see Accompanists Github for details and the android docs for how to implement it in traditional view systems
//inside a composable
val cameraPermissionState = rememberPermissionState(android.Manifest.permission.CAMERA)
Text("camera permission enabled = ${cameraPermissionState.hasPermission}")
While this solution will work "just fine" it might come with a pretty steep learning curve. I suggest you go this route only if you intend to start using compose anyhow.
Expanding the functionality of an under development app, I need to show to the user a progress notification dialog. Problem is, I cannot get it done right. Furthermore, I cannot dismiss this notifier properly. Have tried with a clock and a variable set to e.g. "5000ms" and then to "0", without any lack.
What I need to achieve is the following functionality:
a. Check if the tag "storeparsedData" is in a TinyDB, populated with the fetched JSON data. I have this done, following #Taifun advice in my relative question.
b. If the tag is not there (empty list), do a getWeb.gotText block to get the JSON data (this is done with procedure "getWebData". This functions right, but takes a while about 1'35'' or more, so need to show something to the user.
c. While fetching JSON data form web, need to show a "ShowProgressDialog" notifier to the user, so I can cope with the smartphone being seemingly freeze.
d. If the tag "storeparseData" is populated with fetched JSON data, dismiss the notifier.
Have tried the following coding, without relevant success:
Can someone help me out, to achieve this functionality in this app? A blocks code or something to follow and learn, will be awesome.
Thank you all in advance for your answers.
[Edit1]
After #Taifun suggestions, the functionality in question seems to be working, but there is a problem."ShowProgressDialog" block never fires, neither on device or companion. Also where should block "DismissProgressDialog" be attached to disable notifier upon JSON data received?
Here is the reviewed blocks code, for checking stored tags in TinyDB. "ShowProgressDialog" never fires as it should. Are there any suggestion for this issue?
Here is the blocks code for the getWeb function to get the JSON data:
Please advise, with a block code if applicable.Thank you all.
Your progressNotifier.AfterChoosing event never will fire, because that event only fires after choosing something from a Notifier.ShowChooseDialog block, but not for Notifier.ShowMessageDialog blocks. Therefore use a Notifier.ShowChooseDialog block instead and set the second button in that block to empty string.
Your while loop will freeeze your app, as you already realized... You do not need the Clock.Timer event at all to check if your data is there.
Just do it like this: after having received your data in the Web.GotText event and having stored the data in TinyDB, then dismiss the progress dialog and display the message "Database is ready".
Update: Instead of storing your list n times inside the for each in list loop, you should store it only once after the for each in list loop is finished... Same for the DismissProgressDialog and ShowAlert block...
What is the purpose of that join block? You might want to remove it...
My requirement is to put in a place name in a text field and show that in the map, so i used geocomplete js, which works well.
Now my user should be able to put in user defined places like 'my house', for that I need to remove the geocomplete on clicking a 'x' button on top of the map.
How can I implement this?
Thanks in advance
I wouldn't customize the package! When a new version comes out, you'll have to make the same changes you before.
Since you haven't provided any code, I can give you an idea of what I've done with JQuery validation method overrides.
You'll simply have to find the listener (something like $('#listenToThis').on('click', function(){ doThings(); }) in the geocomplete.js file, then override it in a file that is included after geocomplete.
If you're using bundles, just include your file after the geocomplete listener response is defined.
So, after you find those, you can do something similar to the following:
$.validator.methods.number = function (value, element) {
value = floatValue(value);
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:[\s\.,]\d{3})+)(?:[\.,]\d+)?$/.test(value);
}
The function above allowed me to validate client-side numbers that were formatted as currency in JQuery ($).
This overrides the JQuery.validator.methods.number function (a cheating way to override the function without changing the package code), so if you can pinpoint the geocomplete.addSomethingToMap or geocomplete.reactToClick function, you should override it and it will essentially work that way.
Warning, though: you will need to reinclude the changes when you want to reenable the feature. You'll have to override, override, override again. This may not be the best way if they're going to be adding hundreds of different new locations on one screen, but for up to a small unit, such as a dozen, it should be a good solution.
When entering a string in a text type input element in a webview based app, a list of possible words is showed above the virtual keyboard.
In my application the user is not allowed to input arbitrary words, instead only words and phrases from a database are legal.
So, I want to set the list of words from my phonegap app and disable the automatic creation of this list.
Q: Is this possible to create the list - and how?
(This is a phonegap app and I am testing on android, but this might be a problem for webview / text input fields on different platforms)
EDIT:
Just found out (yes, I'm new to android development), that one can disable the suggestion list with: Settings / Language and Keyboard / Android keyboard / Show suggestions.
But of course, this setting should be made only for the app, from inside the app, without user interaction and not changing anything outside the app.
Any chance to get this done?
EDIT 2:
Instead of disabling the suggestion list I tried to use it.
The displayCompletions method of InputMethodManager sounded promising, so I tried the following code:
...
// data member
InputMethodManager mInputMethodManager = null;
...
...
// initialized
mInputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
...
public void showSuggestions(String[] words) {
Log.d(TAG, "showSuggestions (in Java!): " + words.length); // yes, this code is executed
CompletionInfo[] completions = new CompletionInfo[words.length];
for (int i=0; i<words.length; i++) {
completions[i] = new CompletionInfo(i, i, words[i]); // no idea, what the 2 extra integers mean
}
mInputMethodManager.displayCompletions(mView, completions);
}
The method is executed, whenever a new list is available (after the input has changed and the server has answered a request).
However, nothing has changed - the builtin mechanism is still doing its disadvantageous work.
Why don't you use something like the auto complete in jQuery UI.
http://jqueryui.com/demos/autocomplete/
Also, it's not too hard to whip this up yourself in JavaScript.
http://www.javascript-examples.com/autocomplete-demo/
In case there are different variants of virtual keyboard(swype and others) there might be no list of possible words. So, I suppose there is no general solution for not showing this list.
There is a parameter http://developer.android.com/reference/android/widget/TextView.html#attr_android:editorExtras editorExtras which defines parameters passed to input method implementation, but I'm not sure how would you use it in PhoneGap application
Edit:
I suppose you can extend default input method and make it not to show suggestions
inputmethod reference http://developer.android.com/reference/android/inputmethodservice/InputMethodService.html
Providing Custom Software Keyboards
If you are interested in developing your own software keyboards, we highly recommend the following references:
IMEs are implemented as an Android service. Begin by reviewing the Android packages called android.inputmethodservice and android.view.inputmethod, which can be used to implement custom input methods.
The SoftKeyboard sample application in the Android SDK provides an implementation of a software keyboard.
The Android Developer technical articles on onscreen input methods and creating an input method.
found it here http://e-university.wisdomjobs.com/android/chapter-946-288/handling-advanced-user-input.html
I use WebView for my Androind App. I got a problem and request a solution for help.
There is a textfield in the HTML page. When it gets 'focus' and then I call
mWebView.setFocusableInTouchMode(true);
in Java code so that the Android soft-keyboard will pop-up to let me key in.
The problem is I need using multi-thread for some processes in Java and call
mWebView.loadUrl(strJSCall);
as callback to execute JavaScript function, but the keyboard gets hidden!
The way I try is to force the keyboard to show again. But how can the keyboard always show when 'loadUrl' is called?
Dose anyone meet the same issue and solve it already?
Sincerely,
Jr.
The problem with loadUrl is that it interrupts the UI thread and will still close the input method. The only solid way to do this is to check what the cursor is on the webview, and override the default loadUrl behaviour on your webview.
Inside your custom webview:
#Override
public void loadUrl(String url) {
HitTestResult testResult = this.getHitTestResult();
if (url.startsWith("javascript:)" && testResult != null && testResult.getType() == HitTestResult.EDIT_TEXT_TYPE)
{
//Don't do anything right now, we have an active cursor on the EDIT TEXT
//This should be Input Method Independent
}
else
{
super.loadUrl(url);
}
}
This will prevent the native side from loading Javascript from firing when you have focus on a text field in webkit. It's not perfect but it avoids the mess of trying to figure out whether your text field is visible either by the resizing of the WebView. The Javascript executing in the webview should still work fine.
Again, if you need something to update while you're typing, you may have to find another way for Java to communicate with Javascript that doesn't block the UI thread. This is a hard problem that I still haven't solved properly yet.
I have the same problem and haven't fully solved it yet.
I have been able to force the keyboard to show after calling webView.loadUrl, first you need to find out if the keyboard is showing, I used a modified version of this How to check visibility of software keyboard in Android?
then call
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(webview, InputMethodManager.SHOW_IMPLICIT);
But if like me you need to communicate with the JavaScript in the WebView after each key press then this approach causes the keyboard to flicker as it tries to animate up and down. It also misses some of the input depending on how fast you type.
In Android, executing javascript from WebView is one-way: calling WebView.loadUrl("javascript:sub(1,1)"); You can not get the return value directly.
There's a async way to get the JavaScript function return value:
How to get return value from javascript in webview of android?
But in most cases, we need a sync method instead of the async way. For example, while click event is passed into Android WebView's onTouch
method, we want to execute a JavaScript to reading the element information clicked on.
I have tried two solutions:
1. Use Java P/V variable to wrap a sync method from the async on, the solution looks like:
How to get return value from javascript in webview of android?
The solution is totally not working, because wait method will block the execution of JavaScript and JavaScriptInterface. So if we want to get the result of a js
method in a UI Thread. it's not possible.
Use Java Reflection to get the Native Interface of stringByEvaluatingJavaScriptFromString.
Exist stringByEvaluatingJavaScriptFromString for Android
Works very well, the only thing need to care is to initial reflection method when page loaded finished. I tried to initial the reflection inside constructor of WebView, but failed. I think the constructor is async method.