protected override void OnCreate(Bundle savedInstanceState)
        {
            //Retrieve the current users ID
            UserId = GlobalVariables.currentUserId;

            base.OnCreate(savedInstanceState);

            //Link this activity to the Search Resuly layout page
            SetContentView(Resource.Layout.SearchResult);

            LinearLayout searchResultLayout = FindViewById <LinearLayout>(Resource.Id.linearlayoutSearchResults);

            //Set Background color for view
            string color = Resources.GetString(Resource.String.BackgroundColor);

            searchResultLayout.SetBackgroundColor(Android.Graphics.Color.ParseColor(color));

            //Navigation
            #region
            ActionBar.SetCustomView(Resource.Layout.action_bar);
            ActionBar.SetDisplayShowCustomEnabled(true);

            //Set the Pressed state of the current nav button to true
            LinearLayout navSearch = FindViewById <LinearLayout>(Resource.Id.navSearch);
            navSearch.Pressed = true;

            //Home
            LinearLayout navHome    = FindViewById <LinearLayout>(Resource.Id.navHome);
            ImageView    navHomeimg = FindViewById <ImageView>(Resource.Id.imgNavHome);

            //Search
            ImageView navSearchimg = FindViewById <ImageView>(Resource.Id.imgNavSearch);

            //New Post
            LinearLayout navNewPost = FindViewById <LinearLayout>(Resource.Id.navNewPost);
            ImageView    navPostimg = FindViewById <ImageView>(Resource.Id.imgNewPost);

            //User
            LinearLayout navUser    = FindViewById <LinearLayout>(Resource.Id.navUser);
            ImageView    navUserimg = FindViewById <ImageView>(Resource.Id.imgNavUser);

            //Navigation Home button click event
            navHome.Click += delegate
            {
                var homeAct = new Intent(this, typeof(HomeActivity));
                StartActivity(homeAct);
            };
            navHomeimg.Click += delegate
            {
                var homeAct = new Intent(this, typeof(HomeActivity));
                StartActivity(homeAct);
            };

            //Navigation Search button click event
            navSearch.Click += delegate
            {
                var searchAct = new Intent(this, typeof(SearchActivity));
                StartActivity(searchAct);
            };
            navSearchimg.Click += delegate
            {
                var searchAct = new Intent(this, typeof(SearchActivity));
                StartActivity(searchAct);
            };

            //Navigation New Post button click event
            navNewPost.Click += delegate
            {
                var newpostAct = new Intent(this, typeof(NewPostActivity));
                StartActivity(newpostAct);
            };
            navPostimg.Click += delegate
            {
                var newpostAct = new Intent(this, typeof(NewPostActivity));
                StartActivity(newpostAct);
            };

            //Navigation Profile button click event
            navUser.Click += delegate
            {
                var profileAct = new Intent(this, typeof(MyProfileActivity));
                StartActivity(profileAct);
            };
            navPostimg.Click += delegate
            {
                var profileAct = new Intent(this, typeof(MyProfileActivity));
                StartActivity(profileAct);
            };
            #endregion

            mListView = FindViewById <ListView>(Resource.Id.lstSearchResults);

            //This data will be pulled from the database, but for now it is hardcoded
            mItems = new List <Post>();

            List <Post> userPosts = new List <Post>();

            //Hardcoding Posts - this will be pulled from the database
            Post post1 = new Post();
            post1.ActivityTitle = "Weekly Tennis";
            post1.ActivitySport = "Tennis";
            post1.ActivityTown  = "Sligo";

            Post post2 = new Post();
            post2.ActivityTitle = "Hillwalking Club";
            post2.ActivitySport = "Hillwalking";
            post2.ActivityTown  = "Galway";

            mItems.Add(post1);
            mItems.Add(post2);

            HomeListViewAdapter adapter = new HomeListViewAdapter(this, mItems);

            mListView.Adapter = adapter;
        }
Exemple #2
0
        protected override void OnCreate(Bundle bundle)
        {
            //Retrieve the current users ID
            UserId = GlobalVariables.currentUserId;

            string page = "";

            base.OnCreate(bundle);

            //Link this activity to the Home layout page
            SetContentView(Resource.Layout.Home);

            LinearLayout homeLayout = FindViewById <LinearLayout>(Resource.Id.linearlayoutHome);

            //Set Background color for view
            string color = Resources.GetString(Resource.String.BackgroundColor);

            homeLayout.SetBackgroundColor(Android.Graphics.Color.ParseColor(color));

            //Navigation
            #region
            ActionBar.SetCustomView(Resource.Layout.action_bar);
            ActionBar.SetDisplayShowCustomEnabled(true);

            //Set the Pressed state of the current nav button to true
            LinearLayout navHome = FindViewById <LinearLayout>(Resource.Id.navHome);
            navHome.Pressed = true;

            //Nav
            //Home
            //LinearLayout navHome = FindViewById<LinearLayout>(Resource.Id.navHome);
            ImageView navHomeimg = FindViewById <ImageView>(Resource.Id.imgNavHome);

            //Search
            LinearLayout navSearch    = FindViewById <LinearLayout>(Resource.Id.navSearch);
            ImageView    navSearchimg = FindViewById <ImageView>(Resource.Id.imgNavSearch);

            //New Post
            LinearLayout navNewPost = FindViewById <LinearLayout>(Resource.Id.navNewPost);
            ImageView    navPostimg = FindViewById <ImageView>(Resource.Id.imgNewPost);

            //User
            LinearLayout navUser    = FindViewById <LinearLayout>(Resource.Id.navUser);
            ImageView    navUserimg = FindViewById <ImageView>(Resource.Id.imgNavUser);

            //Navigation Home button click event
            navHome.Click += delegate
            {
                //var homeAct = new Intent(this, typeof(HomeActivity));
                //StartActivity(homeAct);
                page = "home";
                NavCicked(page);
            };
            navHomeimg.Click += delegate
            {
                //var homeAct = new Intent(this, typeof(HomeActivity));
                //StartActivity(homeAct);
                page = "home";
                NavCicked(page);
            };

            //Navigation Search button click event
            navSearch.Click += delegate
            {
                //var searchAct = new Intent(this, typeof(SearchActivity));
                //StartActivity(searchAct);
                page = "search";
                NavCicked(page);
            };
            navSearchimg.Click += delegate
            {
                //var searchAct = new Intent(this, typeof(SearchActivity));
                //StartActivity(searchAct);
                page = "search";
                NavCicked(page);
            };

            //Navigation New Post button click event
            navNewPost.Click += delegate
            {
                //var newpostAct = new Intent(this, typeof(NewPostActivity));
                //StartActivity(newpostAct);
                page = "new";
                NavCicked(page);
            };
            navPostimg.Click += delegate
            {
                //var newpostAct = new Intent(this, typeof(NewPostActivity));
                //StartActivity(newpostAct);
                page = "new";
                NavCicked(page);
            };

            //Navigation Profile button click event
            navUser.Click += delegate
            {
                //var profileAct = new Intent(this, typeof(MyProfileActivity));
                //StartActivity(profileAct);
                page = "user";
                NavCicked(page);
            };
            navUserimg.Click += delegate
            {
                //var profileAct = new Intent(this, typeof(MyProfileActivity));
                //StartActivity(profileAct);
                page = "user";
                NavCicked(page);
            };
            #endregion


            mListView = FindViewById <ListView>(Resource.Id.lstHomeItems);

            mItems = new List <Post>();

            //Pull the posts from the database
            Database dbHelper = new Database();
            mItems = dbHelper.getAllPosts();

            HomeListViewAdapter adapter = new HomeListViewAdapter(this, mItems);

            mListView.Adapter = adapter;
        }