Android Question How to cache a Layout that contain a large amount of contacts ???

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi All

I have a layout that contains a list of contacts from the phone. When a user select an entry I hide the panel, so when the user wants to pick another contact I dont have to read the contacts list again as it can take some time.

When the user hits the home key the app is paused. when the app it called again either by pressing the icon or selecting it from the notification bar and they select the 'Contact popup' I dont get anything displayed when is issues panel.visible = true.

I have tried removeviewat/addview from the activity but get errors.

Anyone got some idea's please.

[link]http://stackoverflow.com/questions/...ontacts-loading-in-listview-on-android[/link] is an interesting article, has anyone implement this or can B4A do this ?

Thanks

John.
 

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi LucaMs

thank for the reply, I figured out that removing a view from the activity does not destroy the view itself. All the elements are still available so my routine for 'caching' the already loaded contacts is a follows.

B4X:
Sub load_contacts
     
   
   APPSET.mCu.mVisible = True
   
   If Not(cu.IsInitialized) Then
     cu.Initialize
   End If

   ' // add the main view panel to the current activity.
   If Not(pnlContacts.IsInitialized) Then
     pnlContacts.Initialize("")
     Activity.AddView(pnlContacts, 0, 0, 100%x, 100%y)
     pnlContacts.LoadLayout("contacts")
     pnlContacts.BringToFront
   
     lstContacts.TwoLinesAndBitmap.Label.TextColor = Colors.Black
     lstContacts.TwoLinesAndBitmap.Label.TextSize = 16
     lstContacts.TwoLinesAndBitmap.Label.Typeface = Typeface.DEFAULT_BOLD
     lstContacts.TwoLinesAndBitmap.SecondLabel.TextColor = Colors.Black
     lstContacts.TwoLinesAndBitmap.SecondLabel.TextSize = 14
     lstContacts.TwoLinesAndBitmap.SecondLabel.Typeface = Typeface.DEFAULT  
     lstContacts.TwoLinesAndBitmap.ImageView.SetLayout(lstContacts.TwoLinesAndBitmap.ItemHeight * .1,lstContacts.TwoLinesAndBitmap.ItemHeight * .1,lstContacts.TwoLinesAndBitmap.ItemHeight * .8 ,lstContacts.TwoLinesAndBitmap.ItemHeight * .8)   
     lstContacts.FastScrollEnabled = True
     ' // load the data
     refesh_contacts_list
   Else
     Activity.AddView(pnlContacts, 0, 0, 100%x, 100%y)
     pnlContacts.Visible = True
     pnlContacts.BringToFront
   End If
   
   

   
End Sub

I guess you can learn something new every day :)

J.
 
Upvote 0
Top