Android Question StdAction Bar Question

Discussion in 'Android Questions' started by jahswani, May 27, 2015.

  1. jahswani

    jahswani Active Member Licensed User

    I'm filling dynamically the bar listIems with this routine

    Code:
    Sub LoadCat
        curs = db.LoadCatz
        
    For i=0 To curs.RowCount-1
          curs.Position=i
       CatArr.AddAll(
    Array As String(curs.GetString("categorie_name")))
        
    Next
        bar.SetListItems (CatArr)
        
    End Sub
    Call here here
    Code:
    Sub Activity_Create(FirstTime As Boolean)
        CatArr.Initialize
        db.Initialize
        
    Activity.LoadLayout("products")
        
    Activity.SetBackgroundImage(LoadBitmap(File.DirAssets, "blue.png"))
        LoadCat
        FillListView
    End Sub
    But everytime on create this fool is fired how can i prevent him from firing himself.
    Code:
    Sub bar_ListItemSelected (Index As Int, Value As String)
       
    Log("Selected value: " & Value)
       ListView1.Clear
       curs=db.LoadCatEntry(Value) 
      curs.Position=
    0
      
    Dim bmp As Bitmap
           
    Dim In1 As InputStream
          
    Dim buffer() As Byte     
           
    Dim num As Int
    For i=0 To curs.RowCount-1
      curs.Position=i
           ListView1.AddTwoLinesAndBitmap(curs.GetString(
    "product_name"),curs.GetString("product_sn")&"  "&MyMethods.MyCurrencyFormatWS(curs.GetString("product_price")),bmp)
           num = i+
    1
    Next
    ToastMessageShow("Number of Records " & num,True)
    End Sub
    Thanks...
     
  2. DonManfred

    DonManfred Expert Licensed User

    The sub does not call itself....

    The sub is raised multiple times. See life time circle of an activity.
     
  3. jahswani

    jahswani Active Member Licensed User

    Is there a solution bro
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Add a global boolean variable: ListItemSelectedFiredOnce. Set it to false before you set the list items. In the event sub check whether it is false or true. If it is false then ignore the event (and change it to true).
     
  5. jahswani

    jahswani Active Member Licensed User

    Ok thanks @Erel i will try it...
     
  6. jahswani

    jahswani Active Member Licensed User

    Solved
     
    Last edited: May 28, 2015
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice