android autocomplete only show word match first letter - android

I'm new to android, now trying to implement autocomplete, my code is as follows
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, COUNTRIES);
AutoCompleteTextView textView = (AutoCompleteTextView)
findViewById(R.id.editText1);
Logger.getLogger("text").info(textView.getText().toString());
textView.setAdapter(adapter);
textView.setThreshold(1);
whereCOUNTRIES is a list of words like canada, america, when i type c, the dropdown list only have word canada in it, how can i change the code so that word america can also show? Thanks

Related

Why is My Listview is not showing my items?

I have a listview that I want to show several items. However, after the program compiles, nothing shows up and I am unsure as to why.
ListView listView = findViewById(R.id.quikList);
ArrayList<String> list = new ArrayList<String>();
list.add("Hello");
list.add("Is it me youre looking for?");
list.add("I can see it in your smile and I want so badly to make this listview work");
ArrayAdapter<String> aa = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, list);
listview.setAdapter(aa);
I don't know why this pretty basic task is not working. I think it might be due to android.R.id.text1, but I'm not sure as to why. Any sort of light anyone can shed on this topic would be fantastic.
No need of 3rd param just remove this line android.R.id.text1
ArrayAdapter<String> aa = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, list);
listView.setAdapter(aa);
Solution 2:
May be your theme issues which means your Textview color same as Listview background color..
so just change your listview background color...
android:background="#android:color/holo_red_dark"
Try this:
ListView listView = (Listview)findViewById(R.id.quikList);
String list[] = {"Hello","Is it me youre looking for?","I can see it in your smile and I want so badly to make this listview work"};
ArrayAdapter<String> aa = new ArrayAdapter<String>(this, R.layout.simple_list_item_1, R.id.textView, list);
listview.setAdapter(aa);

Set Spinner adapter then EditText input type changed

I have set spinner to ArrayAdapter as String list.
// Creating adapter for spinner
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(LoginActivity.this, R.layout.row_spinner, countryCodeList);
dataAdapter.setDropDownViewResource(R.layout.row_spinner);
// attaching data adapter to spinner
spinnerCountryCode.setAdapter(dataAdapter);
In this set spinner adapter successfully but LoginActivity I have also other EditText control as InputType number.
My problem is after spinner adapte set click on Edittext then first open number keyboard and then after immediate open system text keyboard.
I have also set EditText input type as number
android:inputType="number"
And manifest file set windowSoftInputMode is
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
Please suggest me some solution.
Thanks in advance..!
something is wrong with your R.layout.row_spinner , try adding android.R.layout.simple_spinner_item in place of R.layout.row_spinner and run once
ArrayList<String> values;
values = new ArrayList<>();
values.add("value1");
values.add("value1");
values.add("value1");
values.add("value1");
// Creating adapter for spinner
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_spinner_item, values);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
// attaching data adapter to spinner
spinner.setAdapter(dataAdapter);

How to change the search criteria of auto complete text view in android

ive looked for an example that takes a autocompletetextview with a criteria of search diferent than "starts with", for example....
ive got this code :
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, Autos);
AutoCompleteTextView textView = (AutoCompleteTextView)
findViewById(R.id.autoCompleteTextView1);
textView.setThreshold(2);
textView.setAdapter(adapter);
the values of the array:
private static final String[] Autos= new String[] {
"porsche", "pontiac", "volkswagen", "algoconpoentremedio", "tricipo"
};
i want to type "po" in the autocompleteview and i want to recieve : porsche, pontiac, algoconpoentremedio and tricipo, now iam getting only porsche and pontiac, so, what i want its to change the criteria from "starts with" to "contains", is this possible?, if possible an example would be great, since my english aint that good, when i read code in an example i get it way faster. thx in advance.

Array Adapter Issue

I'm trying to input an array into a ListView. I've gotten it to work for a spin box with this code:
Spinner spinner = (Spinner) findViewById(R.id.location_spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, model.getLocationsArray());
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
When I run the next block of code the program closes unexpectedly. Strangely if I remove model.getLocationsArray() it runs but the view won't update.
ListView listView = (ListView) findViewById(R.id.available_locations_list);
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, model.getLocationsArray());
listView.setAdapter(adapter);
Thanks in advance!
model.getLocationsArray() instead this... you can use directly Arraylist object. If you have.Nullpointer Exc. because of from your EditText value cant be added to your ArrayList.

listView Search in android?

I create listView by use the following code.If i use lv.setTextFilterEnabled(true);
i get the list View filter.If i set the filter text its not display the filtered listView.How to set the filter text;
lv=new ListView(this);
lv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_checked, items));
//lv.setTextFilterEnabled(true);
lv.setFilterText("a");
Note :
I have the TextViews A to Z . When i touch letter 'a' i wish to list the elements starts with 'a' so that i need to set the list filter at run time.
Try this code:
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_checked, items);
lv.setListAdapter(adapter);
lv.setTextFilterEnabled(true);
adapter.getFilter().filter("a");

Categories

Resources