Skip to content

Instantly share code, notes, and snippets.

@dsibinski
Created April 2, 2017 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsibinski/b6dcbf1dc0956b584188282c2cb832a2 to your computer and use it in GitHub Desktop.
Save dsibinski/b6dcbf1dc0956b584188282c2cb832a2 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using MoneyBack.Entities;
using MoneyBack.Orm;
namespace MoneyBack
{
[Activity(Label = "@string/activityPeopleListTitle")]
public class PeopleListActivity : ListActivity
{
private List<Person> _peopleList;
protected override async void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
var repo = new Repository<Person>();
_peopleList = await GetPeopleAsync();
this.ListAdapter = new ArrayAdapter<Person>(this, Android.Resource.Layout.SimpleListItem1, _peopleList);
InitializeUserControlsEvents();
}
private async Task<List<Person>> GetPeopleAsync()
{
var repo = new Repository<Person>();
var people = await repo.GetAll();
return people.ToList();
}
private void InitializeUserControlsEvents()
{
this.ListView.ItemClick += ListView_ItemClick;
}
private void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
{
var person = _peopleList[e.Position];
var uri = Android.Net.Uri.Parse("tel:" + person.PhoneNumber);
var intent = new Intent(Intent.ActionDial, uri);
StartActivity(intent);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment