How can I pick Android Word suggestions programmatically from Android?
Asked
Active
Viewed 371 times
2 Answers
1
You can use AutoCompleteTextView for example:
public class CountriesActivity extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.countries);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, COUNTRIES);
AutoCompleteTextView textView = (AutoCompleteTextView)
findViewById(R.id.countries_list);
textView.setAdapter(adapter);
}
private static final String[] COUNTRIES = new String[] {
"Belgium", "France", "Italy", "Germany", "Spain"
};
} or use this link: How to include suggestions in Android Keyboard

Seyed Masood Khademi
- 163
- 1
- 9
0
Ok, then you can use a database like Realm and store your data into the DB. Then fetch the data in EditText's addTextChangedListener.
edtFolderName.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
RealmResults <ObjectClass> results = realm.where(ObjectClass.class)
.like("name",s.toString+"*") // feild name
.findAll();
//You can display this values inside your spinner
}
@Override
public void afterTextChanged(Editable s) {
}
});

Afinas EM
- 2,755
- 1
- 15
- 28