Problem with AutoCompleteEditText ??

ashchopra

Member
Licensed User
Longtime User
Hi Could some spot the problem here.

The AutoCompleteEditText works perfectly well as it should with the lines of the original example posted elsewhere in this forum. But doesnot show the drop down list in the code attached. The original working code is commented out.

The file being loaded with some names is also attached and would have to be copied to probably /mnt/sdcard/

:BangHead::BangHead:
 

Attachments

  • ACET(Mod).zip
    7.5 KB · Views: 242
Last edited:

ashchopra

Member
Licensed User
Longtime User
Oops

Sorry about that Erel. I didnot know which place maybe a better place to ask for help. Also, I was unaware of the Zip option. Will be more careful next time.
:sign0013:

Any one any idead why the AutocompleteEditText si not working with the list loaded from the text file ??
:BangHead:
 

ashchopra

Member
Licensed User
Longtime User
Some Code Works , Some DoesNot

I cant figure this out but AutoCompleteEditText works in a For-Next Loop and Not in a Do-While Loop. I have used Logging of the output to see that the variable ''line'' does indeed get populated in both cases, but in the case of the Do-While Loop the AutoCompleteEditText doesnot work.

Code given below:-
Dim TextReader1 As TextReader
Dim line As String
Dim Items As List

''****************** ThisCodeWorks*****************
Items.Initialize
TextReader1.Initialize(File.OpenInput(File.DirRootExternal, "List.txt"))

For i = 0 To 138
line = TextReader1.ReadLine
Items.Add(line)
Next

TextReader1.Close
AutoCompleteEditText1.SetItems(Items)

''**********End of Working Code******************



''**************This Code Does Not Work***********
Items.Initialize
TextReader1.Initialize(File.OpenInput(File.DirRootExternal, "List.txt"))

line = TextReader1.ReadLine
Items.Add(line)
Do While line <> Null
line = TextReader1.ReadLine
Items.Add(line)
Loop

TextReader1.Close
AutoCompleteEditText1.SetItems(Items)
''*********End of Non Working Code*******************

:sign0163::sign0163:
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Sorry about that Erel. I didnot know which place maybe a better place to ask for help. Also, I was unaware of the Zip option. Will be more careful next time.
No problem. Currently attachments are stored inside the forum database. This makes the attachments a performance problem.

Anyway there is a mistake in your code:
B4X:
line = TextReader1.ReadLine
Items.Add(line)
Do While line <> Null
line = TextReader1.ReadLine
Items.Add(line)
Loop
You are adding a Null value to the items on the last iteration. You should change it to:
B4X:
line = TextReader1.ReadLine
Do While line <> Null
Items.Add(line)
line = TextReader1.ReadLine
Loop

Or even better:
B4X:
Items = File.ReadList(...)
 

ashchopra

Member
Licensed User
Longtime User
Thanks Erel, I did notice the log showing the Null value at the end, but didnot realise that that was causing the problem. Thanks again. !!
 
Top