Android Question load txtfile with number phones and load in edittext in order

fifiddu70

Well-Known Member
Licensed User
Longtime User
hello everyone, as the title suggests I need to create an app that allows me to upload a list of phone numbers through a txt text document on the root external directory, through these numbers I should have one number uploaded in another edittext sequentially, if for example there are 16 numbers on the edittext on the other I should load the first number of the 16 and by pressing a button load the next number but without the paragraph number, in the edittext I would only like to load the number and not for example
1) 398763345
2) 398723745
only
398763345
398723745,
an important thing ... if for example at 7) the app should come out by mistake, I would like it to continue from 7) and so on when it reopens. this is the code i am creating, can anyone help me?
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
fifiddu, non ce se capisce 'na mazza ?
(it is not easily translatable literally; let say: "it is not clear")

Fill a List or Map with the numbers taken from the file and then manage them however you want, using EditTexts, xCustomListView and Buttons.
 
Upvote 0

fifiddu70

Well-Known Member
Licensed User
Longtime User
Think (use) also to Regex.Split and/or SubString2.
i use substring2 now in edittext i see the number without paragrapher, now i try to load in edittext the numbers loaded in numbers sequenzially about press one button, i hope is ok.
B4X:
Sub leggi_Click
    rp.CheckAndRequest(rp.PERMISSION_READ_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult ( Permission As String, Result As Boolean)
    If Result Then
        
        'We are not initializing the list because it just holds the list that returns from File.ReadList
        List1 = File.ReadList(File.DirRootExternal, "numeri_telefono.txt")
        MsgboxAsync("Numeri Telefonici Caricati = " & List1.Size, "")
        spnumeri.AddAll(List1)       
        txtdati.Text= List1.Get(0)
        txtdati.Text = txtdati.Text.SubString(2)
    End If
    
End Sub

Sub timerset_Tick
    timerset.Enabled=False
    If connected Then
        TextWriter1.Write("ATH")
        TextWriter1.Flush
        
        contatore = contatore +1
        txtdati.Text= List1.Get(0+contatore)
        txtdati.Text = txtdati.Text.SubString(2)
        imgchiamata_Click
    End If
End Sub

Sub imgchiamata_Click
    If connected Then
        
        TextWriter1.Write(txtdati.Text)
        TextWriter1.Flush
        timerset.Enabled=True
        Else
            MsgboxAsync("Attenzione non sei connesso", "ERRORE CONNESSIONE")
        
    End If
End Sub

with this code is ok, but i possible use listview and remove spinner ? the list view is good because i see other number in progress.
 
Last edited:
Upvote 0

fifiddu70

Well-Known Member
Licensed User
Longtime User
thank lucaMs, i know as use xcustomlistview you have an example of use in my little code?
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
List1 = File.ReadList(File.DirRootExternal, "numeri_telefono.txt")
The simplest:
B4X:
    Private xclvPhoneNumbers As CustomListView

    For Each PhoneNum As String In List1
        xclvPhoneNumbers.AddTextItem(PhoneNum, "")
    Next
(as you can see in the contextual help writing ".AddTextItem", the second parameter can be a value (any value you want, even an index, for example, or the name of the contact or any other value of any type) to be associated to the list item)
 
Last edited:
Upvote 0

fifiddu70

Well-Known Member
Licensed User
Longtime User
i try to insert your code but i know xcustomlistview and receive error, are me sure the error is caused of my person.
B4X:
Sub leggi_Click
    rp.CheckAndRequest(rp.PERMISSION_READ_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult ( Permission As String, Result As Boolean)
    If Result Then
        
        'We are not initializing the list because it just holds the list that returns from File.ReadList
        List1 = File.ReadList(File.DirRootExternal, "numeri_telefono.txt")
        MsgboxAsync("Numeri Telefonici Caricati = " & List1.Size & CRLF & "Il primo numero da chiamare e: " & List1.Get(0), "")
        'spnumeri.AddAll(List1)       
        'txtdati.Text= List1.Get(0)
        'txtdati.Text = txtdati.Text.SubString(2)
        For Each PhoneNum As String In List1
            xclvPhoneNumbers.AddTextItem(PhoneNum, "")
        Next
    End If
    
End Sub
 
Upvote 0
Top