本文整理汇总了C#中RecyclerView.SetLayoutManager方法的典型用法代码示例。如果您正苦于以下问题:C# RecyclerView.SetLayoutManager方法的具体用法?C# RecyclerView.SetLayoutManager怎么用?C# RecyclerView.SetLayoutManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.SetLayoutManager方法的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;
}
示例2: 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 ());
}
示例3: 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);
}
示例4: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Use this to return your custom view for this Fragment
// return inflater.Inflate(Resource.Layout.YourFragment, container, false);
base.OnCreateView (inflater, container, savedInstanceState);
View View = inflater.Inflate (Resource.Layout.StatsPopUp, container, false);
StatsView = View.FindViewById<RecyclerView> (Resource.Id.statsContainer);
StatsLayoutManager = new LinearLayoutManager (Activity);
StatsView.SetLayoutManager (StatsLayoutManager);
StatsList = new List<Statistic> ();
StatsList.Add (new Statistic () {
Name = "Leben",
Description = "Leben des Helden",
Value = 2,
Image = Resource.Drawable.heart
});
StatsList.Add (new Statistic () { Name = "Mana", Value = 20000000, Image = Resource.Drawable.heart });
StatsList.Add (new Statistic () { Name = "Stärke", Value = 552, Image = Resource.Drawable.heart });
StatsList.Add (new Statistic () { Name = "Schnelligkeit", Value = 23, Image = Resource.Drawable.heart });
StatsList.Add (new Statistic () { Name = "Intelligenz", Value = 42, Image = Resource.Drawable.heart });
StatsList.Add (new Statistic () { Name = "Ansehen", Value = 12, Image = Resource.Drawable.heart });
StatsList.Add (new Statistic ());
StatsView.SetAdapter (new StatisticRecyclerAdapter (StatsList));
return View;
}
示例5: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Instantiate the photo album:
mPhotoAlbum = new PhotoAlbum();
// Set our view from the "main" layout resource:
SetContentView (Resource.Layout.Main);
// Get our RecyclerView layout:
mRecyclerView = FindViewById<RecyclerView> (Resource.Id.recyclerView);
//............................................................
// Layout Manager Setup:
// Use the built-in linear layout manager:
mLayoutManager = new LinearLayoutManager (this);
// Or use the built-in grid layout manager (two horizontal rows):
// mLayoutManager = new GridLayoutManager
// (this, 2, GridLayoutManager.Horizontal, false);
// Plug the layout manager into the RecyclerView:
mRecyclerView.SetLayoutManager (mLayoutManager);
//............................................................
// Adapter Setup:
// Create an adapter for the RecyclerView, and pass it the
// data set (the photo album) to manage:
mAdapter = new PhotoAlbumAdapter (mPhotoAlbum);
// Register the item click handler (below) with the adapter:
mAdapter.ItemClick += OnItemClick;
// Plug the adapter into the RecyclerView:
mRecyclerView.SetAdapter (mAdapter);
//............................................................
// Random Pick Button:
// Get the button for randomly swapping a photo:
Button randomPickBtn = FindViewById<Button>(Resource.Id.randPickButton);
// Handler for the Random Pick Button:
randomPickBtn.Click += delegate
{
if (mPhotoAlbum != null)
{
// Randomly swap a photo with the top:
int idx = mPhotoAlbum.RandomSwap();
// Update the RecyclerView by notifying the adapter:
// Notify that the top and a randomly-chosen photo has changed (swapped):
mAdapter.NotifyItemChanged(0);
mAdapter.NotifyItemChanged(idx);
}
};
}
示例6: 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));
};
}
示例7: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
setup();
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
drawerList = FindViewById<RecyclerView>(Resource.Id.left_drawer);
drawerLayout.SetDrawerShadow(Resource.Drawable.drawer_shadow, GravityCompat.Start);
drawerList.SetLayoutManager(new LinearLayoutManager(this));
adapter = new MenuAdapter();
drawerList.SetAdapter(adapter);
// enable ActionBar app icon to behave as action to toggle nav drawer
this.ActionBar.SetDisplayHomeAsUpEnabled(true);
this.ActionBar.SetHomeButtonEnabled(true);
this.ActionBar.Title = "Test";
drawerToggle = new MainDrawerToggle(this, drawerLayout,
Resource.Drawable.ic_drawer,
Resource.String.drawer_open,
Resource.String.drawer_close);
drawerLayout.AddDrawerListener(drawerToggle);
drawerLayout.CloseDrawer(drawerList);
vm.NavigatedTo(null);
}
示例8: 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;
}
示例9: 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);
}
示例10: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.PhotoLayout1);
_RecyclerView = FindViewById<RecyclerView> (Resource.Id.recyclerView);
var getRequest = new GetRequest ();
var getResponse = new GetResponse ();
getRequest.apiKey = "7gXV0uUd54z3ksYKMAG4co595dDPMaTB";
getRequest.accessToken = "W88EaRR8PiKZXzoDe16eqlnt96CRSj0WFeEfy9ie9N565frGPqM4OVMKVOEdo9qGrYuT4ifeS2eNqrx3P6cBG6hTB3uTFfZawyOh";
getRequest.langCode = "en-GB";
String url = String.Format ("http://api.powhealth.com/LabTestService.svc/api/labtests/byuser/list/{0}/{1}/{2}", getRequest.apiKey, getRequest.accessToken, getRequest.langCode);
WebRequest request = WebRequest.Create (url);
WebResponse response = request.GetResponse ();
var dataStream = response.GetResponseStream ();
StreamReader reader = new StreamReader (dataStream);
string responseFromServer = reader.ReadToEnd ();
reader.Close ();
response.Close ();
var jsonObject = JsonConvert.DeserializeObject <GetResponse> (responseFromServer);
//_LayoutManager = new LinearLayoutManager (this);
_LayoutManager = new GridLayoutManager (this, 2, GridLayoutManager.Vertical, false);
_RecyclerView.SetLayoutManager (_LayoutManager);
_Adapter = new RecyclerAdapter (jsonObject.LabTestsUserOnlyResult, _RecyclerView);
_RecyclerView.SetAdapter (_Adapter);
}
示例11: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.MyVote_Main);
progressDialog = ProgressDialog.Show (this, "Sila Tunggu", "Sedang Memuatkan...");
//initiliaze jsonvalue
// MyVote_Data myVoteData = new MyVote_Data();
mRecyclerView = FindViewById <RecyclerView> (Resource.Id.recyclerView);
var toolbar = FindViewById <Toolbar> (Resource.Id.toolbar);
SetSupportActionBar (toolbar);
var mLayoutManager = new LinearLayoutManager (this);
mRecyclerView.SetLayoutManager (mLayoutManager);
//error layout
llMyPosterErrorLayout = (LinearLayout)FindViewById (Resource.Id.llMyPosterErrorLayout);
tvMyPosterErrorLayout = (TextView)FindViewById (Resource.Id.tvMyPosterErrorLayout);
setupMyVoteData (page);
if (mRecyclerView != null ) {
mRecyclerView.HasFixedSize = true;
var layoutManager = new LinearLayoutManager (this);
var onScrollListener = new MyVote.MyVoteMAPOAdapter.MyvoteRecyclerViewOnScrollListener (layoutManager);
onScrollListener.LoadMoreEvent += (object sender, EventArgs e) => {
page++;
lastPage=MyVote_Data.getLastPage ();
if (page <= lastPage && isRefeshing == false) {
ThreadPool.QueueUserWorkItem (o => {
setupMyVoteData (page);
});
}
};
mRecyclerView.AddOnScrollListener (onScrollListener);
mRecyclerView.SetLayoutManager (layoutManager);
}
}
示例12: OnCreateView
public override Android.Views.View OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Bundle savedInstanceState)
{
var ignored = base.OnCreateView (inflater,container,savedInstanceState);
var view = (ViewGroup)inflater.Inflate (Resource.Layout.layout_news, null);
var viewGroup = (ViewGroup)inflater.Inflate (Resource.Layout.layout_group, null);
string string_key = "41f579fc-1445-4065-ab10-c06d50e724d3";
//NewsDetail = new NewsFragmentDetail ();
//var mFragmentItemContainer = viewGroup.FindViewById<FrameLayout> (Resource.Id.fragment4Container);
Button button = viewGroup.FindViewById<Button> (Resource.Id.btnDetalle);
mFrameLayoutContainer = view.FindViewById<FrameLayout> (Resource.Id.RelativeLay);
var trans = Activity.SupportFragmentManager.BeginTransaction ();
//trans.Add (mFragmentItemContainer.Id, new NewsFragmentDetail (), "Detail");
//trans.Add (Resource.Id.layout_content, NewsDetail);
//trans.Hide (NewsDetail);
mCurrentFragment = this;
trans.Commit ();
mRecyclerView = view.FindViewById<RecyclerView> (Resource.Id.RecyclerViewer);
//Pruebas
//cocoservices.tinnova.mx.COCOService cliente = new Navigation_View.cocoservices.tinnova.mx.COCOService ();
//Navigation_View.cocoservices.tinnova.mx.PublicationDTO[] mPublicacion = new Navigation_View.cocoservices.tinnova.mx.PublicationDTO[5];
//Produccion
services_911consumidor_com.COCOService cliente = new Navigation_View.services_911consumidor_com.COCOService();
Navigation_View.services_911consumidor_com.PublicationDTO[] mPublicacion = new Navigation_View.services_911consumidor_com.PublicationDTO[5];
mPublicacion = cliente.GetActivePublications (string_key);
mPublicaciones = new List<Publicaciones> ();
foreach (PublicationDTO value in mPublicacion) {
mPublicaciones.Add (new Publicaciones {
Titulo = value.Tittle,
FechaPublicacion = value.PublicationDate,
Subtitulo = value.SubTittle,
Imagen = value.ImageUrl,
IdPublicacion = value.Id,
Contenido = value.Content
});
}
mLayoutManager = new LinearLayoutManager (view.Context);
mRecyclerView.SetLayoutManager (mLayoutManager);
mAdapter = new adapter_listview (mPublicaciones, mRecyclerView, view.Context);
mRecyclerView.SetAdapter (mAdapter);
return view;
// Create your fragment here
}
示例13: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = (View) inflater.Inflate(Resource.Layout.cardView_layout,container, false);
//CardView
mRecyclerView = view.FindViewById<RecyclerView>(Resource.Id.recyclerView);
mCardViewHuoJing = new List<CardViewHuoJing>();
FragmentManager fragmentManager1 = this.FragmentManager;
string strURL= this.Resources.GetString(Resource.String.HttpUri)+ String.Format("andriod/bjxx_intime_andriod.jsp?") + String.Format("userId={0}&userType={1}",LogInfoCardView.userId,LogInfoCardView.userType);
Console.WriteLine (strURL);
mHttpRequestCardView.HttpRequestFunc (strURL);
doc.LoadXml(mHttpRequestCardView.HttpRecv);
foreach (XmlNode node in doc.SelectNodes("FireIntime/Info/Fire"))
{
mCardViewHuoJing.Add (new CardViewHuoJing (){
bjxxbh=node.Attributes["bjxxbh"].Value,
dwmc=node.Attributes["dwmc"].Value,
lxdz=node.Attributes["lxdz"].Value,
lxr=node.Attributes["lxr"].Value,
khlb=node.Attributes["khlb"].Value,
gddh=node.Attributes["gddh"].Value,
bjdz=node.Attributes["bjdz"].Value,
asebh=node.Attributes["asebh"].Value,
ipphone=node.Attributes["ipphone"].Value,
quhao=node.Attributes["quhao"].Value,
bjsj=node.Attributes["bjsj"].Value,
bjjb=node.Attributes["bjjb"].Value,
flag=node.Attributes["flag"].Value,
bn=node.Attributes["bn"].Value
});
}
//mCardViewHuoJing.Add(new Email() { Name = "tom", Subject = "Wanna hang out?", Message = "I'll be around tomorrow!!" });
mLayoutManager = new LinearLayoutManager(Application.Context);
mRecyclerView.SetLayoutManager(mLayoutManager);
mAdapter = new RecyclerAdapter(mCardViewHuoJing, mRecyclerView,1,Application.Context,fragmentManager1);
mRecyclerView.SetAdapter(mAdapter);
//swipeRefresh
mSwipeRefreshLayout = view.FindViewById<SwipeRefreshLayout> (Resource.Id.swipeLayout);
mSwipeRefreshLayout.SetColorScheme (Android.Resource.Color.HoloBlueBright, Android.Resource.Color.HoloRedLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloPurple);
mSwipeRefreshLayout.Refresh += mSwipeRefreshLayout_Refresh;
//mRecyclerView.Click += mRecyclerView_Click;
return view ;
}
示例14: OnActivityCreated
public override void OnActivityCreated(Bundle savedInstanceState)
{
base.OnActivityCreated(savedInstanceState);
mRecyclerView = (RecyclerView)mParentView.FindViewById(Resource.Id.recycler_view).JavaCast<RecyclerView>();
LinearLayoutManager manager = new LinearLayoutManager(mRecyclerView.Context);
manager.Orientation=LinearLayoutManager.Horizontal;
mRecyclerView.SetLayoutManager(manager);
mRecyclerView.SetAdapter(new RecyclerViewAdapter(Activity));
}
示例15: FindAndBindViews
public void FindAndBindViews()
{
mRecycler = FindViewById<RecyclerView>(Resource.Id.rvList);
mRecycler.SetLayoutManager(new LinearLayoutManager(this));
refresher = FindViewById<SwipeRefreshLayout>(Resource.Id.refresher);
refresher.Refresh += (sender, e) => OnRefresh(sAccount);
refresher.SetColorSchemeResources(Android.Resource.Color.HoloRedLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloGreenLight);
mAdapter = new BaseRecyclerViewAdapter<UserModel, UserViewHolder>(BaseContext, new List<UserModel>(), Resource.Layout.Item_UserView);
mRecycler.SetAdapter(mAdapter);
}