Guest User

Untitled

a guest
Apr 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. public ListView myList;
  2. List < string>Contacts = new List< string>();
  3.  
  4. protected override void OnCreate(Bundle savedInstanceState)
  5. {
  6. base.OnCreate(savedInstanceState);
  7. SetContentView(Resource.Layout.Control);
  8. myList = FindViewById<ListView>(Resource.Id.clientsList);
  9. myList.ItemLongClick += MyList_ItemLongClick;
  10. }
  11.  
  12. public void insertContact(string ContactInfo)
  13. {
  14. list =FindViewById<ListView>(Resource.Id.contactssList);
  15. contacts.Add(clientInfo);
  16. ArrayAdapter<string> myArray = new ArrayAdapter<string>(Application.Context, Android.Resource.Layout.SimpleListItem1, contacts);
  17. list.Adapter = null;
  18. list.Adapter = myArray;
  19. myList.DeferNotifyDataSetChanged();
  20. }
  21.  
  22. public void startAsync(){
  23. Contacts con = new Contacts();
  24. Thread thread = new Thread(()=> con.Start());
  25. thread.Start();
  26. }
  27.  
  28. MainAct main = new MainAct();
  29. main.insertContact("new Contact");
  30.  
  31. public ListView getListView()
  32. {
  33. ListView myList = FindViewById<ListView>(Resource.Id.contactssList);
  34. return myList;
  35. }
  36.  
  37. main.insertClient("what", main.getListView());
  38.  
  39. main.RunOnUIThread(()=> main.insertClient("what", main.getListView()));
Add Comment
Please, Sign In to add comment