protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_list_view);

            Title = "ListView";

            ListView listView = FindViewById <ListView>(Resource.Id.list_view);

            LayoutInflater layoutInflater = LayoutInflater;

            View     header         = layoutInflater.Inflate(Resource.Layout.list_item_header_footer, null);
            View     footer         = layoutInflater.Inflate(Resource.Layout.list_item_header_footer, null);
            TextView txtHeaderTitle = (TextView)header.FindViewById(Resource.Id.txt_title);
            TextView txtFooterTitle = (TextView)footer.FindViewById(Resource.Id.txt_title);

            txtHeaderTitle.Text = "THE HEADER!";
            txtFooterTitle.Text = "THE FOOTER!";

            listView.AddHeaderView(header);
            listView.AddFooterView(footer);

            SampleAdapter adapter = new SampleAdapter(this, Resource.Id.txt_line1);

            listView.Adapter             = adapter;
            listView.OnItemClickListener = this;

            IList <string> sampleData = SampleData.GenerateSampleData();

            foreach (string data in sampleData)
            {
                adapter.Add(data);
            }
        }
Exemplo n.º 2
0
 private void FillAdapter()
 {
     foreach (string data in mData)
     {
         mAdapter.Add(data);
     }
 }
            public override void OnActivityCreated(Bundle savedInstanceState)
            {
                base.OnActivityCreated(savedInstanceState);

                MGridView = (StaggeredGridView)View.FindViewById(Resource.Id.grid_view);

                if (savedInstanceState == null)
                {
                    LayoutInflater layoutInflater = Activity.LayoutInflater;

                    View     header         = layoutInflater.Inflate(Resource.Layout.list_item_header_footer, null);
                    View     footer         = layoutInflater.Inflate(Resource.Layout.list_item_header_footer, null);
                    TextView txtHeaderTitle = (TextView)header.FindViewById(Resource.Id.txt_title);
                    TextView txtFooterTitle = (TextView)footer.FindViewById(Resource.Id.txt_title);
                    txtHeaderTitle.Text = "THE HEADER!";
                    txtFooterTitle.Text = "THE FOOTER!";

                    MGridView.AddHeaderView(header);
                    MGridView.AddFooterView(footer);
                }

                if (MAdapter == null)
                {
                    MAdapter = new SampleAdapter(Activity, Resource.Id.txt_line1);
                }

                if (MData == null)
                {
                    MData = SampleData.GenerateSampleData();
                }

                foreach (string data in MData)
                {
                    MAdapter.Add(data);
                }

                MGridView.Adapter             = MAdapter;
                MGridView.OnScrollListener    = this;
                MGridView.OnItemClickListener = this;
            }
        private void OnLoadMoreItems()
        {
            List <string> sampleData = SampleData.GenerateSampleData();

            foreach (string data in sampleData)
            {
                mAdapter.Add(data);
            }
            // stash all the data in our backing store
            mData.AddRange(sampleData);
            // notify the adapter that we can update now
            mAdapter.NotifyDataSetChanged();
            mHasRequestedMore = false;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_sgv);

            Title     = "SGV";
            mGridView = (StaggeredGridView)FindViewById(Resource.Id.grid_view);

            LayoutInflater layoutInflater = LayoutInflater;

            View     header         = layoutInflater.Inflate(Resource.Layout.list_item_header_footer, null);
            View     footer         = layoutInflater.Inflate(Resource.Layout.list_item_header_footer, null);
            TextView txtHeaderTitle = (TextView)header.FindViewById(Resource.Id.txt_title);
            TextView txtFooterTitle = (TextView)footer.FindViewById(Resource.Id.txt_title);

            txtHeaderTitle.Text = "THE HEADER!";
            txtFooterTitle.Text = "THE FOOTER!";

            mGridView.AddHeaderView(header);
            mGridView.AddFooterView(footer);
            mAdapter = new SampleAdapter(this, Resource.Id.txt_line1);

            // do we have saved data?
            if (savedInstanceState != null)
            {
                mData = savedInstanceState.GetStringArrayList(SAVED_DATA_KEY).ToList();
            }

            if (mData == null)
            {
                mData = SampleData.GenerateSampleData();
            }

            foreach (string data in mData)
            {
                mAdapter.Add(data);
            }

            mGridView.Adapter                 = mAdapter;
            mGridView.OnScrollListener        = this;
            mGridView.OnItemClickListener     = this;
            mGridView.OnItemLongClickListener = this;
        }