Created
April 2, 2017 06:33
-
-
Save dsibinski/b6dcbf1dc0956b584188282c2cb832a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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