Пример #1
0
        public async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            this.newsSource    = savedInstanceState.GetString("newsSource");
            this.mNewsItems    = new List <NewsItem>();
            this.newsInterface = new NewsImplementation();

            this.mNewsItems.Add(new NewsItem("Test", "test", Resource.Drawable.placeholder));


            try
            {
                if (!newsSource.Equals(null) || !newsSource.Equals(""))
                {
                    List <Newsitem> newsItems = await newsInterface.GetPolarNews("Trump", newsSource);

                    foreach (Newsitem item in newsItems)
                    {
                        mNewsItems.Add(new NewsItem(item.Title, item.Description, Resource.Drawable.placeholder));
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            mAdapter = new NewsAdapter(mNewsItems);
            mRecyclerView.SetAdapter(mAdapter);
            mRecyclerView.ScrollToPosition(0);
            mLayoutManager = new LinearLayoutManager(this.Activity);
            mRecyclerView.SetLayoutManager(mLayoutManager);
        }
Пример #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (container == null)
            {
                return(null);
            }

            View view = inflater.Inflate(Resource.Layout.home_layout, null);

            this.Activity.SetContentView(view);

            TextView source = (TextView)view.FindViewById(Resource.Id.nav_label);

            source.Text = "Source: " + newsSource;

            mRecyclerView = (RecyclerView)view.FindViewById(Resource.Id.recyclerView);
            mAdapter      = new NewsAdapter(mNewsItems);
            mRecyclerView.SetAdapter(mAdapter);
            mRecyclerView.ScrollToPosition(0);
            mLayoutManager = new LinearLayoutManager(this.Activity);
            mRecyclerView.SetLayoutManager(mLayoutManager);

            return(view);
        }