本文整理汇总了C#中RecyclerView.GetAdapter方法的典型用法代码示例。如果您正苦于以下问题:C# RecyclerView.GetAdapter方法的具体用法?C# RecyclerView.GetAdapter怎么用?C# RecyclerView.GetAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.GetAdapter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: OnScrolled
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
{
base.OnScrolled (recyclerView, dx, dy);
var visibleItemCount = recyclerView.ChildCount;
var totalItemCount = recyclerView.GetAdapter().ItemCount;
var pastVisiblesItems = LayoutManager.FindFirstVisibleItemPosition();
if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
LoadMoreEvent (this, totalItemCount);
}
}
示例3: OnScrolled
public override void OnScrolled (RecyclerView recyclerView, int dx, int dy)
{
base.OnScrolled (recyclerView, dx, dy);
var visibleItemCount = recyclerView.ChildCount;
// Console.Error.WriteLine ("isRefeshing"+MySoal_Tab_1.isRefeshing);
//
if (MyHealth_Tab_2.isRefreshing) {
Console.Error.WriteLine ("masuk");
MyHealth_Tab_2.worker.CancelAsync ();
if (MyHealth_Tab_2.worker.CancellationPending) {
if (MyHealth_Tab_2.worker.IsBusy == true)
{
}
}
}
var totalItemCount = recyclerView.GetAdapter().ItemCount;
var lastVisibleItem = ((LinearLayoutManager)recyclerView.GetLayoutManager()).FindLastCompletelyVisibleItemPosition();
if ((lastVisibleItem+1) == totalItemCount) {
Console.Error.WriteLine ("scrolll222");
LoadMoreEvent (this, null);
}
}
示例4: OnScrolled
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
{
View firstVisibleView = recyclerView.GetChildAt(0);
int firstVisiblePosition = recyclerView.GetChildPosition(firstVisibleView);
int visibleRange = recyclerView.ChildCount;
int lastVisiblePosition = firstVisiblePosition + visibleRange;
int itemCount = recyclerView.GetAdapter().ItemCount;
int position;
if(firstVisiblePosition==0)
position=0;
else if(lastVisiblePosition==itemCount-1)
position = itemCount-1;
else
position = firstVisiblePosition;
float proportion=(float)position/(float)itemCount;
this.scroll.setPosition(scroll.height*proportion);
}
示例5: OnScrolled
public override void OnScrolled (RecyclerView recyclerView, int dx, int dy)
{
base.OnScrolled (recyclerView, dx, dy);
var visibleItemCount = recyclerView.ChildCount;
var totalItemCount = recyclerView.GetAdapter().ItemCount;
var lastVisibleItem = ((LinearLayoutManager)recyclerView.GetLayoutManager()).FindLastCompletelyVisibleItemPosition();
if ((lastVisibleItem+1) == totalItemCount) {
LoadMoreEvent (this, null);
}
}
示例6: OnScrolled
public override void OnScrolled (RecyclerView recyclerView, int dx, int dy)
{
pref = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
LinearLayoutManager linearLayoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager ();
int lastVisibleItem = linearLayoutManager.FindLastVisibleItemPosition();
int totalItemCount = recyclerView.GetAdapter().ItemCount;
if (!IsLoading && totalItemCount <= (lastVisibleItem + visibleThreshold)) {
// End has been reached
// Do something
var currPrefPage = pref.GetString ("CurrentPage", string.Empty);
if (!String.IsNullOrEmpty (currPrefPage)) {
if (Int32.Parse (currPrefPage) > 0) {
currentPage++;
} else {
currentPage = 2;
}
} else {
currentPage++;
}
var editor = pref.Edit();
editor.PutString("CurrentPage",currentPage.ToString());
editor.Apply();
IsLoading = true;
Task.Factory.StartNew (async () => {
try{
var newPostList = new List<Post>();
await WebClient.LoadPosts(newPostList,currentPage);
(recyclerView.GetAdapter()as PostViewAdapter)._Posts.AddRange(newPostList);
//recyclerView.GetAdapter().HasStableIds = true;
_messageShown = false;
Application.SynchronizationContext.Post (_ => {recyclerView.GetAdapter().NotifyDataSetChanged();}, null);
//recyclerView.GetAdapter().NotifyItemRangeInserted(recyclerView.GetAdapter().ItemCount,newPostList.Count);
}catch(Exception ex){
//Insights.Report(ex,new Dictionary<string,string>{{"Message",ex.Message}},Insights.Severity.Error);
var text = ex.Message;
if(!_messageShown){
Application.SynchronizationContext.Post (_ => {
Toast.MakeText(Application.Context,"При загрузке данных произошла ошибка",ToastLength.Short).Show();
}, null);
_messageShown = true;
}
}
IsLoading = false;
});
}
}
示例7: CanDismiss
public bool CanDismiss (RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder)
{
var adapter = recyclerView.GetAdapter ();
return adapter.GetItemViewType (viewHolder.LayoutPosition) == RecyclerCollectionDataAdapter<IHolder>.ViewTypeContent;
}
示例8: CanRecyclerViewScroll
public static bool CanRecyclerViewScroll(RecyclerView view)
{
if (view == null || view.GetAdapter() == null || view.GetLayoutManager() == null)
return false;
RecyclerView.LayoutManager lm = view.GetLayoutManager();
int count = view.GetAdapter().ItemCount;
int lastVisible;
if (lm is LinearLayoutManager)
{
LinearLayoutManager llm = (LinearLayoutManager)lm;
lastVisible = llm.FindLastVisibleItemPosition();
}
else
{
throw new InvalidOperationException("Material Dialogs currently only supports LinearLayoutManager. Please report any new layout managers.");
}
if (lastVisible == -1)
return false;
bool lastItemVisible = lastVisible == count - 1;
return !lastItemVisible ||
(view.ChildCount > 0 && view.GetChildAt(view.ChildCount - 1).Bottom > view.Height - view.PaddingBottom);
}
示例9: CanDismiss
public bool CanDismiss (RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder)
{
var adapter = recyclerView.GetAdapter ();
return adapter.GetItemViewType (viewHolder.LayoutPosition) == LogTimeEntriesAdapter.ViewTypeContent;
}