Android -- AutocompleteTextView dropdown question - android

So here's my issue.
String[] list = ws.getList() ///returns a String[] of 2900 elements.
AutoCompleteTextView actv= (AutoCompleteTextView)findViewById(R.id.field);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.dropdownmenu, list);
actv.setAdapter(adapter);
My question is... when I run my application, my autocompletetextview does not generate any sort of text whenever I type in it. However, if I shorten my list to like, 30 elements, it works perfectly. Are autocompletetextviews limited to a certain amount of items?
Thanks!

I have an autocompletetextview in an app i'm developping that has about 5000 entries and it works fine.
However, it is significantly slow on a real device without debugging set to true. So if you run it in the emulator it is very likely that you are not seeing anything as it would take a long long type to perform filtering and then display the suggestions.
To my knowledge, there is no limit on the numbers of item

I'm having the same issue. I've been running a lot of tests to try slim down the problem.
I'm using an xml file to supply the array to my autocomplete field.
In 2.2 the activity crashes when the array is too large.
In 2.3 the same array doesn't cause any issues at all.
My array consists of around 950 nodes.
Once I slim it doen to about 200 it's fine. (I didn't note the exact number that causes a crash.)

I had a similar issue but some of my Strings were null or empty, because the data was pulled from an unfamiliar database. I created my list like this and it works just fine. The empty or null strings in the list prevent the dropdown from opening.
if(mystring!=null && !mystring.isEmpty())
{
//add to list here
}
Maybe your test of 30 is working because you know each string has a value. I did a similar test and found that it worked, which led me to the solution/idea above... two years later... I wonder if he's still stuck on this problem ;)

Related

Save and Load contents TStringGrid

I have a simple form containing TstringGrid with 2 columns, a TStringColumn and TCheckColumn added. I have seen many examples of saving the contents to file if the cells contain text or numbers. I have not seen any examples of saving with a TCheckColumn. I am assuming that I must check each CheckColumn cell, determine its state and assign a value that can be saved to file. Or maybe there is a more elegant way to do this.
As for sorting - again many examples using strings or numbers but none with TCheckColumn. I have HeaderClick enabled. On the TStringColumn I would like to sort Alphabetically - On the TCheckColumn - I would like checked items at the top of the column.
I am using Delphi 10.2.1 and will compile for Android.
Without saying you shouldn't start from here - I will just answer the specific questioN;
To keep it simple, I would:
Save: iterate through the rows and take the state of the checkboxes and prefix the string item with BoolToStr(theCheckValue)+':'+theContents of the string.
Then save the stringList.
To Load:
load into the stringList and then iterate and break the string apart using pos on the ':' and StrToBool the left portion, setting the checked item based on this.
Not got an IDE up, so haven't tested, but that would be my approach as a bit of a hack.

2d ArrayList Using ListView

I want to build program looks like this.
I'm getting confused how i can build it like this. The only possibilities in my mind is only using ListView. But really i already searching in many sites how to make it looks like this, but i didn't found it.
So that i already give the mark in the picture. That data is coming from database. So for the example in the first record contain Ship-001 , CDD, Indah Transport, 5 Nov 2015. And the second record is Ship-002, CDE, Buana Karya, 6 Nov 2015, and so on.
Could u help me to provide me about this ?
so a listview use data in the form of array. every item in the array, will contain one record, for example, item 1 contains ("Ship-001" , "CDD", "Indah Transport", "5 Nov 2015").
then use the list view to show all the items.
this is a great tutorial for listview
list view tutorial

I can't figure out how to make a table in android, that gives a summary of the hours registered

I find designing my android App really hard. Don't even know where to start. I just want to make a simple table like this:
didn't allow me to post a picture.
here's the link:
It has to be created with code since the 5 rows(15/04-15 - hverdag -1337 - 3 -2 and so on) are depending on how many registered hours the person has created in a time interval of a week. So it could be 1 or 100 rows.
You can easily manage your task by creating columns in a listview, and you can populate its adapter via data from anywhere you want. Here are some links for showing that stuff :
For creating a multicolumn ListView from this link.
and for showing how to populate your custom adapter follow this link.
Hope this helps.

Android - Do I need to sort a collection for min and max?

I came here (SO) a few days ago to research how to get the min and max from a collection in Android and found a solution to the effect of the following (sorry haven't got a link to the actual answer I used):
Max = (TextView)findViewById(R.id.Max);
Collections.sort(list);
Max.setText(String.format("%.2f", Collections.max(list)));
My question is do I actually need to sort the list before pulling the min/max value? I have tried running the code without sorting the list and it seems to work OK. I am just worried because the answer I used definitely sorted the list first so I assume there must be a reason, I just don't know what it is!
In addition #BobbyDigital's answer who corectly points out the th method iterates over the complete list, I would just like to mention that the result of using the max function might depend on the type of the list elements. If you see the doc , it says that
Returns the maximum element of the given collection, according to the natural ordering of its elements.
If you see Why does Collections.max() not return actual max value for a Collection of String? question, the person used a list of Strings. On extracting max using the abve number he did not get the max number as it was returning the value that's the largest lexicographically. So, just to mention his code:
ArrayList<String> dirNo = new ArrayList<String>();
dirNo.add("1");
dirNo.add("2");
dirNo.add("3");
dirNo.add("4");
dirNo.add("5");
dirNo.add("6");
dirNo.add("7");
dirNo.add("8");
dirNo.add("9");
dirNo.add("10");
dirNo.add("11");
System.out.println("max : " + Integer.parseInt(Collections.max(dirNo))
+ "");
The above code gave 9 as the answer. So be careful while using it. You mgiht want to convert everything to Integer etc based on your needs.
P.S: The example is from the question mentioned and the answer is inspired from this answer by NPE on same question.
No it doesn't have to be sorted. The method iterates over the entire collection.
See the Java docs for the method!

GPS data -> MySQL -> Android sorted ListView

I'm programming an Android app that shows data from MySQL database via ListView with some sorting:
1) Items that are closer to android phone by GPS are shown firstly
If there are 2 or more items with equal distance, second sorting parameter applies - time.
2) Items that are closer in time are showm firstly.
Here is a scheme of the process that I guess to implement:
My idea is to get all needed rows into Array, then make some PHP manipulations with it and then pull sorted Array to the phone.
(as shown on the image above)
So please advice me what will be the proper way?
Maybe there is easier method for this functionality?
Or maybe I should do all the sortings exactly in the Android app when programming ListView, getting only standard "SELECT *" array from the database? Then, is there an opportunity to create a ListView with sorting based on calculated values?

Categories

Resources