Android Question Help needed on list or excel

bbfit

New Member
Hi experts,
I'm trying to create a app that can show me price of things i search.
i have created the interface with login password, but i'm stuck at how to create a list.

eg.
house = $50
car = $100
games = $25

a app that i search for "house" in textbox, then btn_click, label will display $50.

Please advise what code is best to use to store my list.
Sorry, i'm still learning and new to B4A programming.
Do not know if use excel will be a better way too.

Thank you
 

Mahares

Expert
Licensed User
Longtime User
Do not know if use excel will be a better way too.
Use a map. Here is a complete project for you as a beginner that does what you want to get started, but you have to read about map and see videos. You can paste this in a project and see how it works for now, very simple to give you an idea:
B4X:
Sub Globals
    Private btn As Button
    Private edt As EditText
    Private lbl As Label
    Private mp As Map
End Sub

Sub Activity_Create(FirstTime As Boolean)
    mp.Initialize
    mp.Put("house", 50)
    mp.Put("car", 100)
    mp.Put("games", 25)  'then you can store the map into a file and retrieve the map when you want to
    
    edt.Initialize("edt")
    Activity.AddView(edt, 0,0, 200dip, 75dip)
    edt.Hint="Enter object here"
    
    lbl.Initialize("lbl")
    Activity.AddView(lbl,300dip,0,150dip,75dip)  'via code, but you can do it via designer
    lbl.Color=Colors.Blue

    btn.Initialize("btn")
    Activity.AddView(btn,200dip,300dip, 150dip, 100dip)
    btn.Text="Click me"
    btn.Color=Colors.Red
End Sub

Sub btn_Click
    lbl.Text="$" & mp.Get(edt.Text)
End Sub]/code]
 
Upvote 0

bbfit

New Member

How do i store the map into a file? And code to read out the dir and filename to get the data ?
Thank you
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
How do i store the map into a file? And code to read out the dir and filename to get the data ?
See this link for how to read a map from a file and how to save a map to a file:
Search in the forum for more information. There is a ton of valuable info. See also klaus's booklets. The link to the booklets are in @klaus signature. See also videos by Erel. Links in his signature.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…