Is there any method to autocomplete a text in an edittext?
Is there any method to autocomplete a text in an edittext?
The problem is, now I have 3 fixed string like Dev123, Dev456,Abc.
Below is the value user put in the edittext, and the output I wish.
@郭奇靂 Why are you posting in the javascript tag? Aren't you using Android Studio (and thus Java)?
– Chris G
Jul 3 at 7:48
Java != JavaScript. Which are you using?
– jhpratt
Jul 3 at 7:52
Sorry,fixed, java
– 郭奇靂
Jul 3 at 8:07
1 Answer
1
Here is a very generic code to help you with listening for text inputs and making changes to input values.
EditText editor = (EditText) findViewById(R.id.editText);
editor.addTextChangedListener(watcher);
private TextWatcher watcher = new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// Just a sample to give you an idea. Build your own logic here.
if(s=='A'){
editor.setText("Abc");
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
};
this cannot fix the problem of mine,I had tried this. I need if user enter both A,Ab,Abc it will come out Abc. If there's a method that can do it without lots of if?
– 郭奇靂
Jul 3 at 8:06
here's my current code mServerUrlText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean b) { if(b == false){ if(mServerUrlText.getText().toString() == App.Env_KmartDev){ } } } });
– 郭奇靂
Jul 3 at 8:08
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Have you tried anything, do you have any code? Have you tried to research this, or just asked the question first?
– Archer
Jul 3 at 7:47