本文整理匯總了Java中android.support.v7.widget.RecyclerView.Adapter方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.Adapter方法的具體用法?Java RecyclerView.Adapter怎麽用?Java RecyclerView.Adapter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.Adapter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onAdapterChanged
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void onAdapterChanged(RecyclerView.Adapter oldAdapter,
RecyclerView.Adapter newAdapter) {
if (oldAdapter != null && measureSupporter.isRegistered()) {
try {
measureSupporter.setRegistered(false);
oldAdapter.unregisterAdapterDataObserver((RecyclerView.AdapterDataObserver) measureSupporter);
} catch (IllegalStateException e) {
//skip unregister errors
}
}
if (newAdapter != null) {
measureSupporter.setRegistered(true);
newAdapter.registerAdapterDataObserver((RecyclerView.AdapterDataObserver) measureSupporter);
}
//Completely scrap the existing layout
removeAllViews();
}
示例2: onScrolled
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
final int childCount = recyclerView.getChildCount();
if (childCount > 0) {
View lastChild = recyclerView.getChildAt(childCount - 1);
RecyclerView.Adapter outerAdapter = recyclerView.getAdapter();
int lastVisible = recyclerView.getChildAdapterPosition(lastChild);
if (lastVisible == outerAdapter.getItemCount() - 1 && hasNextPage() && canLoadNextPage()) {
onLoadNextPage();
}
}
}
示例3: HeaderViewRecyclerAdapter
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public HeaderViewRecyclerAdapter(RecyclerView.Adapter adapter) {
mHeaderViews = new ArrayList<>();
mFooterViews = new ArrayList<>();
mItemTypesOffset = new HashMap<>();
setWrappedAdapter(adapter);
}
示例4: initRecyclerViewH
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* 配置水平列表RecyclerView
* @param view
*/
public static void initRecyclerViewH(Context context, RecyclerView view, boolean isDivided,
RecyclerView.Adapter adapter) {
LinearLayoutManager layoutManager = new LinearLayoutManager(context);
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
view.setLayoutManager(layoutManager);
view.setItemAnimator(new DefaultItemAnimator());
if (isDivided) {
view.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.HORIZONTAL_LIST));
}
view.setAdapter(adapter);
}
示例5: dispatchUpdateTo
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void dispatchUpdateTo(@NonNull RecyclerView.Adapter adapter) {
if(mType == Type.ADDED)
adapter.notifyItemInserted(mNewPosition);
if(mType == Type.MOVED)
adapter.notifyItemMoved(mOldPosition, mNewPosition);
if(mType == Type.NEW_LIST || mType == Type.NEW_LIST_FROM_CACHE)
adapter.notifyDataSetChanged();
if(mType == Type.REMOVED)
adapter.notifyItemRemoved(mOldPosition);
if(mType == Type.UPDATED)
adapter.notifyItemChanged(mOldPosition);
}
示例6: test_findFirstCompletelyVisibleItem
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Test
public void test_findFirstCompletelyVisibleItem() {
RecyclerView.Adapter adapter = AdapterBuilder.newBuilder(mActivity).build();
// Utils.setupLayoutTest(null, adapter, mLayoutManager, mRecyclerView);
Assert.assertEquals(0, mLayoutManager.findFirstCompletelyVisibleItemPosition());
}
示例7: setAdapter
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void setAdapter(RecyclerView.Adapter adapter) {
if (mWrappedAdapter != null && mWrappedAdapter.getItemCount() > 0) {
notifyItemRangeRemoved(getHeaderCount(), mWrappedAdapter.getItemCount());
}
setWrappedAdapter(adapter);
notifyItemRangeInserted(getHeaderCount(), mWrappedAdapter.getItemCount());
}
示例8: build
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public RecyclerView.Adapter build() {
return null;
}
示例9: getOriginalAdapter
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public RecyclerView.Adapter getOriginalAdapter() {
return this.adapter;
}
示例10: getAdapter
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public RecyclerView.Adapter getAdapter() {
return mAdapter;
}
示例11: getWrappedAdapter
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public RecyclerView.Adapter getWrappedAdapter() {
return wrapped;
}
示例12: getAdapter
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected RecyclerView.Adapter getAdapter() {
mAdapter = new EventAdapter();
return mAdapter;
}
示例13: addAdapter
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void addAdapter(RecyclerView.Adapter adapter) {
addAdapter(adapter, true);
}
示例14: setAdapterData
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
void setAdapterData(RecyclerView.Adapter adapter, List<Video> data) {
((VideosAdapter)adapter).setData(data);
}
示例15: LoadMoreWrapper
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public LoadMoreWrapper(RecyclerView.Adapter adapter)
{
mInnerAdapter = adapter;
}