本文整理匯總了Java中android.support.v7.widget.RecyclerView.getContext方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.getContext方法的具體用法?Java RecyclerView.getContext怎麽用?Java RecyclerView.getContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.getContext方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawVertical
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawVertical(Canvas c, RecyclerView parent)
{
final int left = parent.getPaddingLeft();
final int right = parent.getWidth() - parent.getPaddingRight();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++)
{
final View child = parent.getChildAt(i);
RecyclerView v = new RecyclerView(
parent.getContext());
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
.getLayoutParams();
final int top = child.getBottom() + params.bottomMargin;
final int bottom = top + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
示例2: drawVertical
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawVertical(Canvas c, RecyclerView parent) {
final int left = parent.getPaddingLeft();
final int right = parent.getWidth() - parent.getPaddingRight();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
android.support.v7.widget.RecyclerView v = new android.support.v7.widget.RecyclerView(parent.getContext());
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
.getLayoutParams();
final int top = child.getBottom() + params.bottomMargin;
final int bottom = top + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
示例3: bindView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void bindView(@NonNull RecyclerView view) {
super.bindView(view);
mSwipeItemTouchListener = new SwipeItemTouchListener(view.getContext(), mGroupBasicAdapter, getContentView());
if (mSwipeCardActionEdge != -1) {
mSwipeItemTouchListener.setActionEdge(mSwipeCardActionEdge);
}
view.addOnItemTouchListener(mSwipeItemTouchListener);
view.setOnScrollListener(new RecyclerView.OnScrollListener(){
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (recyclerView != null) {
scrolledY += dy;
}
}
});
}
示例4: drawVertical
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawVertical(Canvas c, RecyclerView parent)
{
final int left = parent.getPaddingLeft() + DIVIDER_PADING_LEFT;
final int right = parent.getWidth() - parent.getPaddingRight();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++)
{
final View child = parent.getChildAt(i);
RecyclerView v = new RecyclerView(
parent.getContext());
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
.getLayoutParams();
final int top = child.getBottom() + params.bottomMargin;
final int bottom = top + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
示例5: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
RecyclerView view = new RecyclerView(getActivity());
view.setLayoutManager(new LinearLayoutManager(getActivity(),
LinearLayoutManager.VERTICAL, false));
view.setAdapter(mAdapter);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(view.getContext(),
LinearLayoutManager.VERTICAL);
view.addItemDecoration(dividerItemDecoration);
view.setOnScrollListener(new OnLoadMoreListener() {
@Override
public void onLoadMore() {
loadPage();
}
});
return view;
}
示例6: setItems
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@BindingAdapter("items")
public static void setItems(RecyclerView recyclerView, Collection<Image> items) {
ImagesAdapter adapter = new ImagesAdapter(recyclerView.getContext());
ArrayList<ImagesAdapter.ImageItem> list = new ArrayList<>();
if (items != null) {
for (Image image : items) {
list.add(new ImagesAdapter.ImageItem(image));
}
}
adapter.setImages(list);
recyclerView.setAdapter(adapter);
}
示例7: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
RecyclerView recyclerView = (RecyclerView) inflater.inflate(
R.layout.recycler_view, container, false);
ContentAdapter adapter = new ContentAdapter(recyclerView.getContext());
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
return recyclerView;
}
示例8: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_blocks, container, false);
tvStatus = (TextView) rootView.findViewById(R.id.tvStatus);
mRecyclerView = (RecyclerView) rootView.findViewById(R.id.my_recycler_view);
// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
mRecyclerView.setHasFixedSize(true);
// use a linear layout manager
mLayoutManager = new LinearLayoutManager(getContext());
mRecyclerView.setLayoutManager(mLayoutManager);
DividerItemDecoration horizontalDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
DividerItemDecoration.VERTICAL);
Drawable horizontalDivider = ContextCompat.getDrawable(getActivity(), R.drawable.divider_grey);
horizontalDecoration.setDrawable(horizontalDivider);
mRecyclerView.addItemDecoration(horizontalDecoration);
// specify an adapter (see also next example)
mAdapter = new BlocksAdapter(blocks);
mAdapter.setOnItemClickListener(this);
mRecyclerView.setAdapter(mAdapter);
refreshUI();
return rootView;
}
示例9: applySettings
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public static void applySettings(RecyclerView recyclerView){
recyclerView.setHasFixedSize(true);
recyclerView.setItemViewCacheSize(5);
recyclerView.setDrawingCacheEnabled(true);
gridLayoutManager = new GridLayoutManager(recyclerView.getContext(), 2);
recyclerView.setLayoutManager(gridLayoutManager);
}
示例10: linear
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* A {@link LinearLayoutManager} with the given orientation and reverseLayout.
*/
public static Factory linear(@Orientation final int orientation, final boolean reverseLayout) {
return new Factory() {
@Override
public RecyclerView.LayoutManager create(RecyclerView recyclerView) {
return new LinearLayoutManager(recyclerView.getContext(), orientation, reverseLayout);
}
};
}
示例11: smoothScrollToPosition
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state,
int position) {
View firstVisibleChild = recyclerView.getChildAt(0);
int itemHeight = firstVisibleChild.getHeight();
int currentPosition = recyclerView.getChildLayoutPosition(firstVisibleChild);
int distanceInPixels = Math.abs((currentPosition - position) * itemHeight);
if (distanceInPixels == 0) {
distanceInPixels = (int) Math.abs(firstVisibleChild.getY());
}
SmoothScroller smoothScroller = new SmoothScroller(recyclerView.getContext(), distanceInPixels, duration);
smoothScroller.setTargetPosition(position);
startSmoothScroll(smoothScroller);
}
示例12: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shopping_cart);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.shopping_cart_title);
setSupportActionBar(toolbar);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mTextViewEmptyCart = (TextView) findViewById(R.id.text_view_empty_cart);
mTextViewTotalPrice = (TextView) findViewById(R.id.text_view_total_price);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(
mRecyclerView.getContext(), layoutManager.getOrientation());
mCartAdapter = new ShoppingCartAdapter();
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.addItemDecoration(dividerItemDecoration);
mRecyclerView.setAdapter(mCartAdapter);
mButtonCheckout = (Button) findViewById(R.id.button_cart_checkout);
mButtonCheckout.setOnClickListener(this);
getSupportLoaderManager().initLoader(SHOPPING_CART_LOADER, null, this);
}
示例13: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_deviceitem_list, container, false);
// Set the adapter
if (view instanceof RecyclerView) {
mView = view;
Context context = view.getContext();
RecyclerView recyclerView = (RecyclerView) view;
if (mColumnCount <= 1) {
recyclerView.setLayoutManager(new LinearLayoutManager(context));
} else {
recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
}
DeviceManager dm = DeviceManager.getInstance();
dm.unregisterEventListener(mDeviceManagerEventListener);
mDeviceManagerEventListener = new DeviceManagerEventListener() {
@Override
public void onEvent(Event event) {
if (event == Event.DEVICE_LIST_UPDATED || event == Event.DEVICE_STATUS_UPDATED)
updateDeviceList();
}
};
dm.registerEventListener(mDeviceManagerEventListener);
updateDeviceList();
DividerItemDecoration dividerDecoration = new DividerItemDecoration(recyclerView.getContext(),
LinearLayoutManager.VERTICAL);
recyclerView.addItemDecoration(dividerDecoration);
}
return view;
}
示例14: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
RecyclerView recyclerView = (RecyclerView) inflater.inflate(
R.layout.recycler_view, container, false);
ContentAdapter adapter = new ContentAdapter(recyclerView.getContext());
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
Bundle args = getArguments();
idCategoria = args.getInt("category_id",0);
return recyclerView;
}
示例15: setRecycler
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void setRecycler(RecyclerView rv) {
LinearLayoutManager lm = new LinearLayoutManager(context);
rv.setLayoutManager(lm);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(rv.getContext(),
lm.getOrientation());
rv.addItemDecoration(dividerItemDecoration);
ArrayList<AudioBook> items = new ArrayList<>();
adapter = new AudioBookAdapter(context, items, this);
rv.setAdapter(adapter);
interactor.loadNewAudioBooks();
}