protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.fav_list);

            listView = FindViewById<ListView> (Resource.Id.fav_list);
            List<Tweet> allFavTweets = new List<Tweet> ();

            try {
                var dbT = new TweetCommands (this);
                allFavTweets = dbT.GetAllTweets ();

            } catch (System.Exception sysExc) {
                Console.Error.WriteLine ("System.Exception : " + sysExc.Message + "\n" + sysExc.StackTrace);
            }

            if (allFavTweets.Count > 0) {
                try {
                        listAdapter = new MyListAdapter (this, allFavTweets);
                        listView.Adapter = listAdapter;
                        listView.ItemClick += ListClick;

                } catch (WebException we) {
                    Console.Error.WriteLine ("WebException : " + we.Message);
                } catch (System.Exception sysExc) {
                    Console.Error.WriteLine ("System.Exception : " + sysExc.Message + "\n" + sysExc.StackTrace);
                }
            } else {
                Toast.MakeText(this, "Something went wrong", ToastLength.Short).Show();
                StartActivity(typeof (Activity1));
                Finish ();
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.fav_list);

            listView = FindViewById <ListView> (Resource.Id.fav_list);
            List <Tweet> allFavTweets = new List <Tweet> ();

            try {
                var dbT = new TweetCommands(this);
                allFavTweets = dbT.GetAllTweets();
            } catch (System.Exception sysExc) {
                Console.Error.WriteLine("System.Exception : " + sysExc.Message + "\n" + sysExc.StackTrace);
            }

            if (allFavTweets.Count > 0)
            {
                try {
                    listAdapter         = new MyListAdapter(this, allFavTweets);
                    listView.Adapter    = listAdapter;
                    listView.ItemClick += ListClick;
                } catch (WebException we) {
                    Console.Error.WriteLine("WebException : " + we.Message);
                } catch (System.Exception sysExc) {
                    Console.Error.WriteLine("System.Exception : " + sysExc.Message + "\n" + sysExc.StackTrace);
                }
            }
            else
            {
                Toast.MakeText(this, "Something went wrong", ToastLength.Short).Show();
                StartActivity(typeof(Activity1));
                Finish();
            }
        }
예제 #3
0
        public void ListClick(object sender, AdapterView.ItemClickEventArgs args)
        {
            int i = (int) listAdapter.GetItemId (args.Position);
            Toast.MakeText(this, "clicked "+i.ToString (), ToastLength.Short).Show();
            Tweet t = listAdapter.GetTweet (i-1);
            var dbT = new TweetCommands (this);
            dbT.AddTweet (t);

            StartActivity(typeof (ViewFavTweetsActivity));
            Finish ();
        }
예제 #4
0
        public void ListClick(object sender, AdapterView.ItemClickEventArgs args)
        {
            int i = (int)listAdapter.GetItemId(args.Position);

            Toast.MakeText(this, "clicked " + i.ToString(), ToastLength.Short).Show();
            Tweet t   = listAdapter.GetTweet(i - 1);
            var   dbT = new TweetCommands(this);

            dbT.AddTweet(t);

            StartActivity(typeof(ViewFavTweetsActivity));
            Finish();
        }