当前位置: 首页>>代码示例>>C#>>正文


C# RecyclerView类代码示例

本文整理汇总了C#中RecyclerView的典型用法代码示例。如果您正苦于以下问题:C# RecyclerView类的具体用法?C# RecyclerView怎么用?C# RecyclerView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RecyclerView类属于命名空间,在下文中一共展示了RecyclerView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreateView

        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.StudyCardLayout, container, false);
            mRecyclerView = view.FindViewById<RecyclerView> (Resource.Id.recyclerView);
            //mListView = view.FindViewById<ListView> (Resource.Id.lvToDoList);
            mFab = view.FindViewById<FloatingActionButton> (Resource.Id.fab);
            mFab.Click += (sender, e) => {
                createFragment(null,true);
            };
            mStudyGroup = new List<StudyGroup> ();
            StudyRequest asyncStudyRquest = new StudyRequest ();
            Task<StudyResponse> data = asyncStudyRquest.StudyRequestAsync (LoginInfo.username, LoginInfo.KEY);

            StudyResponse results = data.Result;
            List<StudyGroup> resultsList = new List<StudyGroup> (results.studyGroups);

            for (int i = 0; i <resultsList.Count; i++) {

                mStudyGroup.Add (resultsList[i]);
            }

            mLayoutManager = new LinearLayoutManager (view.Context);
            mRecyclerView.SetLayoutManager (mLayoutManager);
            mAdapter = new RecyclerAdapter (mStudyGroup,mRecyclerView,this);
            mRecyclerView.SetAdapter (mAdapter);

            return view;
        }
开发者ID:ScholarStation,项目名称:Android,代码行数:28,代码来源:StudyCardFrag.cs

示例2: OnBindViewHolder

 public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
 {
     var movieViewHolder = (MovieViewHolder)holder;
     movieViewHolder.MovieNameTextView.Text = movies[position].title;
     movieViewHolder.DirectedByTextView.Text = "Directed by " + movies[position].director;
     movieViewHolder.ReleasedOnTextView.Text = "Released on " + movies[position].release_date;
 }
开发者ID:vkoppaka,项目名称:31DaysOfXamarinAndroid,代码行数:7,代码来源:MovieAdapter.cs

示例3: OnBindViewHolder

		public override void OnBindViewHolder (RecyclerView.ViewHolder viewHolder, int position)
		{
			var item = items [position];
			var holder = viewHolder as MyViewHolder2;
			holder.imageView.SetBackgroundResource (items[position]);

		}
开发者ID:kamalthakur2305,项目名称:Xamarin-Multiple-RecyclerView,代码行数:7,代码来源:MyAdapter2.cs

示例4: OnCreateView

        public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate (Resource.Layout.ProjectListFragment, container, false);

            recyclerView = view.FindViewById<RecyclerView> (Resource.Id.ProjectListRecyclerView);
            recyclerView.SetLayoutManager (new LinearLayoutManager (Activity));
            recyclerView.AddItemDecoration (new ShadowItemDecoration (Activity));
            recyclerView.AddItemDecoration (new DividerItemDecoration (Activity, DividerItemDecoration.VerticalList));

            emptyStateLayout = view.FindViewById<LinearLayout> (Resource.Id.ProjectListEmptyState);
            searchEmptyState = view.FindViewById<LinearLayout> (Resource.Id.ProjectListSearchEmptyState);
            tabLayout = view.FindViewById<TabLayout> (Resource.Id.WorkspaceTabLayout);
            newProjectFab = view.FindViewById<AddProjectFab> (Resource.Id.AddNewProjectFAB);
            toolBar = view.FindViewById<Toolbar> (Resource.Id.ProjectListToolbar);

            var activity = (Activity)Activity;
            activity.SetSupportActionBar (toolBar);
            activity.SupportActionBar.SetDisplayHomeAsUpEnabled (true);
            activity.SupportActionBar.SetTitle (Resource.String.ChooseTimeEntryProjectDialogTitle);

            HasOptionsMenu = true;
            newProjectFab.Click += OnNewProjectFabClick;
            tabLayout.SetOnTabSelectedListener (this);

            return view;
        }
开发者ID:alfonsogarciacaro,项目名称:mobile,代码行数:26,代码来源:ProjectListFragment.cs

示例5: OnCreate

        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            recyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerView);
            activityIndicator = FindViewById<ProgressBar>(Resource.Id.activityIndicator);

            activityIndicator.Visibility = Android.Views.ViewStates.Visible;

            layoutManager = new LinearLayoutManager(this, LinearLayoutManager.Vertical, false);

            recyclerView.SetLayoutManager(layoutManager);

            var repository = new MoviesRepository();

            var films = await repository.GetAllFilms();

            var moviesAdapter = new MovieAdapter(films.results);

            recyclerView.SetAdapter(moviesAdapter);

            activityIndicator.Visibility = Android.Views.ViewStates.Gone;

            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(false);
        }
开发者ID:vkoppaka,项目名称:31DaysOfXamarinAndroid,代码行数:26,代码来源:MainActivity.cs

示例6: GetSwipeDirs

 public override int GetSwipeDirs (RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder)
 {
     if (listener.CanDismiss (recyclerView, viewHolder)) {
         return ItemTouchHelper.Right;
     }
     return 0;
 }
开发者ID:eatskolnikov,项目名称:mobile,代码行数:7,代码来源:SwipeDismissCallback.cs

示例7: OnInterceptTouchEvent

        public bool OnInterceptTouchEvent (RecyclerView rv, MotionEvent e)
        {
            // TODO : this part intercep any touch inside recycler
            // and delete pending items.
            // A better method could be used.

            if (e.Action == MotionEventActions.Down) {
                var undoAdapter = (IUndoAdapter)rv.GetAdapter ();
                View view = GetChildViewUnder (e);

                if (view == null) {
                    undoAdapter.DeleteSelectedItem ();
                } else {
                    int position = recyclerView.GetChildLayoutPosition (view);
                    if (!undoAdapter.IsUndo (position)) {
                        undoAdapter.DeleteSelectedItem ();
                    }
                }
            }

            if (IsEnabled) {
                gestureDetector.OnTouchEvent (e);
            }
            return false;
        }
开发者ID:eatskolnikov,项目名称:mobile,代码行数:25,代码来源:ItemTouchListener.cs

示例8: MovieCategoryViewHolder

		public MovieCategoryViewHolder (View itemView, int viewType) : base (itemView) {
			//Creates and caches our views defined in our layout
			if (viewType == 0) // TODO: Calculate this. I don't think this is a good way to ensure consistent presentation across different device resolutions
				itemView.SetPadding (itemView.PaddingLeft, itemView.PaddingTop + 110, itemView.PaddingRight, itemView.PaddingBottom);
			this.CategoryName = itemView.FindViewById<TextView>(Resource.Id.movie_category_item_txtCategoryName);
			this.MovieList = itemView.FindViewById<RecyclerView>(Resource.Id.movie_category_item_lstMovies);
		}
开发者ID:Robert-Altland,项目名称:MovieExplorer,代码行数:7,代码来源:MovieCategoryViewHolder.cs

示例9: OnCreate

		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			SetContentView (Resource.Layout.recyclerview);

			recyclerView = FindViewById<RecyclerView> (Resource.Id.recycler_view);

			// Layout Managers:
			recyclerView.SetLayoutManager (new LinearLayoutManager (this));

			// Item Decorator:
			recyclerView.AddItemDecoration (new DividerItemDecoration (Resources.GetDrawable (Resource.Drawable.divider)));
			recyclerView.SetItemAnimator (new FadeInLeftAnimator ());

			// Adapter:
			var adapterData = new [] {
				"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", 
				"Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", 
				"Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", 
				"Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", 
				"Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", 
				"New Hampshire", "New Jersey", "New Mexico", "New York", 
				"North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", 
				"Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", 
				"Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", 
				"West Virginia", "Wisconsin", "Wyoming"
			};
			adapter = new RecyclerViewAdapter (this, adapterData.ToList ());
			adapter.Mode = Attributes.Mode.Single;
			recyclerView.SetAdapter (adapter);

			// Listeners
			recyclerView.SetOnScrollListener (new ScrollListener ());
		}
开发者ID:Dealtis,项目名称:oldDMS_3,代码行数:34,代码来源:RecyclerViewExample.cs

示例10: OnCreate

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

            _persoon = Gegevens.GetPerson();
            _groep = Gegevens.CurrentGroup();

            SetContentView(Resource.Layout.Betaalscherm);

            _toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            ImageView Avatar = _toolbar.FindViewById<ImageView>(Resource.Id.Avatar);
            TextView Title = _toolbar.FindViewById<TextView>(Resource.Id.Title);
            Title.Text = _groep.groepsnaam;

            foreach (var lid in _persoon.KrijgSchuldGroep(_groep))
            {
                deelnemers.Add(new ListItem(lid.Key, Resource.Drawable.iconn, lid.Value, _groep));
            }

            _adapter = new ListItemAdapter(ListItem.Session, deelnemers);
            _adapter.ItemClick += OnItemClick;
            _adapter.ItemLongClick += (sender, e) => {};

            _recyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerview);
            _recyclerView.SetMinimumHeight(ConvertDptoPx(listItemHeight*deelnemers.Count));
            _recyclerView.SetLayoutManager(new LinearLayoutManager(this));
            _recyclerView.SetScrollContainer(true);
            _recyclerView.NestedScrollingEnabled = false;
            _recyclerView.SetAdapter(_adapter);

            SetSupportActionBar(_toolbar);
            SupportActionBar.Title = "";
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
        }
开发者ID:SansSkill,项目名称:Introproject,代码行数:35,代码来源:Betaalscherm.cs

示例11: OnBindViewHolder

		public override void OnBindViewHolder (RecyclerView.ViewHolder holder, int position)
		{
			//int item = mData[position];
			//IWindowManager windowManager = context.GetSystemService(Context.WindowService).JavaCast<IWindowManager>();
			//MyKomuniti_ViewHolder vh = holder as MyKomuniti_ViewHolder;

				/*//calculate the phone screen
				DisplayMetrics dm = new DisplayMetrics ();
				windowManager.DefaultDisplay.GetMetrics (dm);
				int width = dm.WidthPixels;
				int height = dm.HeightPixels;
				int dens = (int)dm.DensityDpi;
				double wi = (double)width / (double)dens;
				double hi = (double)height / (double)dens;
				double x = Math.Pow (wi,2);
				double y = Math.Pow (hi,2);
				double screenInches = Math.Sqrt (x + y);*/
			//vh.tvTitle.Text = mData[position].title;
			//vh.tvContent.Text = mData[position].content;


			//vh.IVLike.SetImageResource (mData[position].like);
			if (holder.GetType () == typeof(MyKomuniti_ViewHolder)) {
				MyKomuniti_ViewHolder vh = holder as MyKomuniti_ViewHolder;
				vh.tvTitle.Text = mData[position].title;
				//vh.tvContent.Text = mData[position].content;
				vh.tvDescription.Text = Html.FromHtml(mData[position].content).ToString();
				//vh.tvDescription.Text = mData[position].content.Replace("s/<(.*?)>//g","");
				vh.tvMKVLIDate.Text = mData [position].date;
				vh.tvMKVLISender.Text = mData [position].sender;
			}
		}
开发者ID:kktanpiya,项目名称:pyongPyaa048,代码行数:32,代码来源:RecyclerViewAdapter.cs

示例12: OnQueryTextChange

 /// <summary>
 /// Raises the query text change event.
 /// Filters the user list in the UsersViewModel by wether the entered string is contained in the users first/last name 
 /// </summary>
 /// <param name="newText">Text entered in the SearchView by the user</param>
 public bool OnQueryTextChange(string newText)
 {
     _recyclerView = FindViewById<RecyclerView> (Resource.Id.user_list);
     _filteredUsers = _usersViewModel.Users.ToList ().FindAll (e => (e.FirstName.ToLower() + " " + e.LastName.ToLower()).Contains (newText.ToLower()));
     SetupRecyclerView (_recyclerView);
     return true;
 }
开发者ID:GrillPhil,项目名称:EnterpriseApps,代码行数:12,代码来源:UserListActivity.cs

示例13: OnCreate

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

			// Set our view from the "main" layout resource
			this.SetContentView (Resource.Layout.movie_detail);

			// Create your application here
			var strConfig = this.Intent.Extras.GetString ("Configuration");
			var strSelectedMovie = this.Intent.Extras.GetString ("SelectedMovie");
			this.configuration = JsonConvert.DeserializeObject<ConfigurationResponse> (strConfig);
			this.movieDetail = JsonConvert.DeserializeObject<Movie> (strSelectedMovie);

			this.btnPlay = this.FindViewById<Button> (Resource.Id.movie_detail_btnPlay);
			this.btnPlay.Click += this.btnPlay_Click;
			this.btnFavorite = this.FindViewById<Button> (Resource.Id.movie_detail_btnFavorite);
			this.btnFavorite.Click += this.btnFavorite_Click;
			this.btnClose = this.FindViewById<ImageButton> (Resource.Id.movie_detail_close);
			this.btnClose.Click += this.btnClose_Click;
			this.txtTitle = this.FindViewById<TextView> (Resource.Id.movie_detail_txtTitle);
			this.txtReleaseDate = this.FindViewById<TextView> (Resource.Id.movie_detail_txtReleaseDate);
			this.ratingBar = this.FindViewById<RatingBar> (Resource.Id.movie_detail_ratingBar);
			this.txtVoteCount = this.FindViewById<TextView> (Resource.Id.movie_detail_txtVoteCount);
			this.txtOverview = this.FindViewById<TextView> (Resource.Id.movie_detail_txtOverview);
			this.imgPoster = this.FindViewById<ImageView> (Resource.Id.movie_detail_imgPoster);
			this.vwSimilarMovies = this.FindViewById<RelativeLayout> (Resource.Id.movie_detail_vwSimilarMovies);
			this.movieList = this.FindViewById<RecyclerView>(Resource.Id.movie_detail_lstSimilarMovies);
			this.movieLayoutManager = new LinearLayoutManager (this, LinearLayoutManager.Horizontal, false);
			this.movieList.SetLayoutManager (this.movieLayoutManager);

			this.updateLayout ();
		}
开发者ID:Robert-Altland,项目名称:MovieExplorer,代码行数:31,代码来源:MovieDetailActivity.cs

示例14: OnInterceptTouchEvent

 public bool OnInterceptTouchEvent (RecyclerView rv, MotionEvent e)
 {
     if (IsEnabled) {
         gestureDetector.OnTouchEvent (e);
     }
     return false;
 }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:7,代码来源:ItemTouchListener.cs

示例15: OnCreate

		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.activity_recycler_view_add_remove);
			ActionBar.SetDisplayHomeAsUpEnabled (true);
			ActionBar.SetDisplayShowHomeEnabled (true);
			ActionBar.SetIcon (Android.Resource.Color.Transparent);

			recyclerView = FindViewById<RecyclerView> (Resource.Id.recycler_view);
			recyclerView.HasFixedSize = true;


			layoutManager = new LinearLayoutManager (this);
			recyclerView.SetLayoutManager (layoutManager);

			adapter = new RecyclerAdapter (new List<RecyclerItem>());
			recyclerView.SetAdapter (adapter);
			recyclerView.SetItemAnimator (new DefaultItemAnimator ());

			FindViewById<Button>(Resource.Id.add).Click += (sender, e) => {
				adapter.Add(new RecyclerItem { Title = "New Item: " + adapter.ItemCount });
			};

			adapter.OnItemClick = (view, item) => {
				adapter.Remove(adapter.Items.IndexOf(item));
			};
		}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:27,代码来源:RecyclerViewActivityAddRemove.cs


注:本文中的RecyclerView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。