예제 #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Friends_Activity);

            Button btnAddFriend = FindViewById <Button>(Resource.Id.btn_addFriend);

            btnAddFriend.Click += async delegate
            {
                GetData  getuser     = new GetData();
                Register register    = new Register();
                EditText userToAdd   = FindViewById <EditText>(Resource.Id.tf_UsernameAdd);
                Friend   friendtoadd = new Friend(getuser.getUserID(), getuser.getUserIDbyUsername(userToAdd.Text));
                try
                {
                    if (userToAdd.Text != "")
                    {
                        await register.addFriend(friendtoadd);
                    }
                }
                catch (Exception)
                {
                    throw new ArgumentException();
                }
            };

            Button btnOpenFriendList = FindViewById <Button>(Resource.Id.btn_openFriendList);

            btnOpenFriendList.Click += delegate {
                StartActivity(typeof(FriendListActivity));
                Finish();
            };

            Button btnGoBackToMain = FindViewById <Button>(Resource.Id.btn_GoBackToMain1);

            btnGoBackToMain.Click += delegate
            {
                SetContentView(Resource.Layout.Main);
                Finish();
            };
        }
예제 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.FriendList_Activity);
            ListView friendListview = FindViewById <ListView>(Resource.Id.friendsview);

            GetData getdata   = new GetData();
            var     FriendsID = new List <int>();
            var     Friends   = new List <string>();

            foreach (string i in getdata.getFriends())
            {
                Friends.Add(i);
                ArrayAdapter <string> adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, Friends);
                friendListview.Adapter = adapter;
            }

            Button btnGoBack = FindViewById <Button>(Resource.Id.btn_goBack);

            btnGoBack.Click += delegate {
                StartActivity(typeof(FriendsActivity));
                Finish();
            };
        }