android.support.v7.widget.GridLayoutManager.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中android.support.v7.widget.GridLayoutManager.<init>()方法的一些代码示例,展示了GridLayoutManager.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridLayoutManager.<init>()方法的具体详情如下:
包路径:android.support.v7.widget.GridLayoutManager
类名称:GridLayoutManager
方法名:<init>

GridLayoutManager.<init>介绍

[英]Creates a vertical GridLayoutManager
[中]创建垂直网格布局管理器

代码示例

代码示例来源:origin: bumptech/glide

@Override
public View onCreateView(
  @NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 View result = inflater.inflate(R.layout.recycler_view, container, false);
 recyclerView = (RecyclerView) result.findViewById(R.id.recycler_view);
 GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 1);
 layoutManager.setOrientation(RecyclerView.HORIZONTAL);
 recyclerView.setLayoutManager(layoutManager);
 recyclerView.setHasFixedSize(true);
 return result;
}

代码示例来源:origin: naman14/Timber

private void setLayoutManager() {
  if (isGrid) {
    layoutManager = new GridLayoutManager(getActivity(), 2);
  } else {
    layoutManager = new GridLayoutManager(getActivity(), 1);
  }
  recyclerView.setLayoutManager(layoutManager);
}

代码示例来源:origin: naman14/Timber

private void setLayoutManager() {
  if (isGrid) {
    layoutManager = new GridLayoutManager(getActivity(), 2);
  } else {
    layoutManager = new GridLayoutManager(getActivity(), 1);
  }
  recyclerView.setLayoutManager(layoutManager);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

@Override
public void initRecyclerView() {
  mRecyclerView.setHasFixedSize(true);
  mRecyclerView.setLayoutManager(new GridLayoutManager(NewBangumiSerialActivity.this, 3));
  mAdapter = new NewBangumiSerialAdapter(mRecyclerView, newBangumiSerials, true);
  mRecyclerView.setAdapter(mAdapter);
  mAdapter.setOnItemClickListener((position, holder) -> {
  });
}

代码示例来源:origin: hitherejoe/animate

private void init(Context context, AttributeSet attrs) {
  if (attrs != null) {
    int[] attrsArray = {
        android.R.attr.columnWidth
    };
    TypedArray array = context.obtainStyledAttributes(attrs, attrsArray);
    mColumnWidth = array.getDimensionPixelSize(0, -1);
    array.recycle();
  }
  mGridLayoutManager = new GridLayoutManager(getContext(), 1);
  setLayoutManager(mGridLayoutManager);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

/**
 * 初始化番剧推荐recyclerView
 */
private void initRecommendRecycler() {
  mBangumiRecommendRecycler.setHasFixedSize(false);
  mBangumiRecommendRecycler.setNestedScrollingEnabled(false);
  mBangumiRecommendRecycler.setLayoutManager(new GridLayoutManager(BangumiDetailsActivity.this, 3));
  BangumiDetailsRecommendAdapter mBangumiDetailsRecommendAdapter = new BangumiDetailsRecommendAdapter(mBangumiRecommendRecycler, bangumiRecommends);
  mBangumiRecommendRecycler.setAdapter(mBangumiDetailsRecommendAdapter);
}

代码示例来源:origin: rengwuxian/RxJavaSamples

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_cache, container, false);
  ButterKnife.bind(this, view);
  cacheRv.setLayoutManager(new GridLayoutManager(getActivity(), 2));
  cacheRv.setAdapter(adapter);
  swipeRefreshLayout.setColorSchemeColors(Color.BLUE, Color.GREEN, Color.RED, Color.YELLOW);
  swipeRefreshLayout.setEnabled(false);
  return view;
}

代码示例来源:origin: rengwuxian/RxJavaSamples

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_elementary, container, false);
  ButterKnife.bind(this, view);
  gridRv.setLayoutManager(new GridLayoutManager(getActivity(), 2));
  gridRv.setAdapter(adapter);
  swipeRefreshLayout.setColorSchemeColors(Color.BLUE, Color.GREEN, Color.RED, Color.YELLOW);
  swipeRefreshLayout.setEnabled(false);
  return view;
}

代码示例来源:origin: TeamNewPipe/NewPipe

protected RecyclerView.LayoutManager getGridLayoutManager() {
  final Resources resources = activity.getResources();
  int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width);
  width += (24 * resources.getDisplayMetrics().density);
  final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels / (double)width);
  final GridLayoutManager lm = new GridLayoutManager(activity, spanCount);
  lm.setSpanSizeLookup(infoListAdapter.getSpanSizeLookup(spanCount));
  return lm;
}

代码示例来源:origin: TeamNewPipe/NewPipe

protected RecyclerView.LayoutManager getGridLayoutManager() {
  final Resources resources = activity.getResources();
  int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width);
  width += (24 * resources.getDisplayMetrics().density);
  final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels / (double)width);
  final GridLayoutManager lm = new GridLayoutManager(activity, spanCount);
  lm.setSpanSizeLookup(itemListAdapter.getSpanSizeLookup(spanCount));
  return lm;
}

代码示例来源:origin: rengwuxian/RxJavaSamples

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_zip, container, false);
  ButterKnife.bind(this, view);
  gridRv.setLayoutManager(new GridLayoutManager(getActivity(), 2));
  gridRv.setAdapter(adapter);
  swipeRefreshLayout.setColorSchemeColors(Color.BLUE, Color.GREEN, Color.RED, Color.YELLOW);
  swipeRefreshLayout.setEnabled(false);
  return view;
}

代码示例来源:origin: TeamNewPipe/NewPipe

protected RecyclerView.LayoutManager getGridLayoutManager() {
  final Resources resources = activity.getResources();
  int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width);
  width += (24 * resources.getDisplayMetrics().density);
  final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels / (double)width);
  final GridLayoutManager lm = new GridLayoutManager(activity, spanCount);
  lm.setSpanSizeLookup(infoListAdapter.getSpanSizeLookup(spanCount));
  return lm;
}

代码示例来源:origin: jeasonlzy/ImagePicker

private void initWidget() {
  RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
  selImageList = new ArrayList<>();
  adapter = new ImagePickerAdapter(this, selImageList, maxImgCount);
  adapter.setOnItemClickListener(this);
  recyclerView.setLayoutManager(new GridLayoutManager(this, 4));
  recyclerView.setHasFixedSize(true);
  recyclerView.setAdapter(adapter);
}

代码示例来源:origin: smuyyh/BookReader

@Override
protected void onBindData(EasyRVHolder viewHolder, int position, BookListTags.DataBean item) {
  RecyclerView rvTagsItem = viewHolder.getView(R.id.rvTagsItem);
  rvTagsItem.setHasFixedSize(true);
  rvTagsItem.setLayoutManager(new GridLayoutManager(mContext, 4));
  TagsItemAdapter adapter = new TagsItemAdapter(mContext, item.tags);
  rvTagsItem.setAdapter(adapter);
  viewHolder.setText(R.id.tvTagGroupName, item.name);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

private void setCoins() {
  int count = mUserCoinsInfo.getData().getCount();
  if (count == 0) {
    coinsLayout.setVisibility(View.GONE);
  }
  List<UserCoinsInfo.DataBean.ListBean> list = mUserCoinsInfo.getData().getList();
  mCoinsRecycler.setHasFixedSize(false);
  mCoinsRecycler.setNestedScrollingEnabled(false);
  mCoinsRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 2));
  mCoinsRecycler.setAdapter(new UserHomePagerCoinsAdapter(mCoinsRecycler, list));
  mCoinsCount.setText(String.valueOf(count));
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

private void setContribute() {
  int count = mUserContributeInfo.getData().getCount();
  if (count == 0) {
    contributeLayout.setVisibility(View.GONE);
  }
  List<UserContributeInfo.DataBean.VlistBean> vlist = mUserContributeInfo.getData().getVlist();
  mContributeRecycler.setHasFixedSize(false);
  mContributeRecycler.setNestedScrollingEnabled(false);
  mContributeRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 2));
  mContributeRecycler.setAdapter(new UserHomePagerContributeAdapter(mContributeRecycler, vlist));
  mContributeCount.setText(String.valueOf(count));
}

代码示例来源:origin: naman14/Timber

private void setLayoutManager() {
  if (isGrid) {
    layoutManager = new GridLayoutManager(getActivity(), 2);
    fastScroller.setVisibility(View.GONE);
  } else {
    layoutManager = new GridLayoutManager(getActivity(), 1);
    fastScroller.setVisibility(View.VISIBLE);
    fastScroller.setRecyclerView(recyclerView);
  }
  recyclerView.setLayoutManager(layoutManager);
}

代码示例来源:origin: facebook/litho

public GridLayoutInfo(
  Context context,
  int spanCount,
  int orientation,
  boolean reverseLayout,
  boolean allowGridMeasuresOverride) {
 mAllowGridMeasureOverride = allowGridMeasuresOverride;
 mGridLayoutManager =
   mAllowGridMeasureOverride
     ? new GridLayoutManager(context, spanCount, orientation, reverseLayout)
     : new LithoGridLayoutManager(context, spanCount, orientation, reverseLayout);
 mGridSpanSizeLookup = new GridSpanSizeLookup();
 mGridLayoutManager.setSpanSizeLookup(mGridSpanSizeLookup);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

@Override
protected void initRecyclerView() {
  mLiveAppIndexAdapter = new LiveAppIndexAdapter(getActivity());
  mRecyclerView.setAdapter(mLiveAppIndexAdapter);
  GridLayoutManager layout = new GridLayoutManager(getActivity(), 12);
  layout.setOrientation(LinearLayoutManager.VERTICAL);
  layout.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
    @Override
    public int getSpanSize(int position) {
      return mLiveAppIndexAdapter.getSpanSize(position);
    }
  });
  mRecyclerView.setLayoutManager(layout);
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onCreate(Bundle state) {
 super.onCreate(state);
 setLayoutManager(new GridLayoutManager(this, 2));
 setAdapter(new IconicAdapter());
}

相关文章