androidx.recyclerview.widget.GridLayoutManager.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(158)

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

GridLayoutManager.<init>介绍

暂无

代码示例

代码示例来源:origin: andkulikov/Transitions-Everywhere

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  mRecyclerView = new RecyclerView(container.getContext());
  mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
    ViewGroup.LayoutParams.MATCH_PARENT));
  mRecyclerView.setLayoutManager(new GridLayoutManager(container.getContext(), 4));
  mRecyclerView.setAdapter(new Adapter());
  return mRecyclerView;
}

代码示例来源:origin: bluelinelabs/Conductor

@Override
protected void onViewBound(@NonNull View view) {
  super.onViewBound(view);
  tvTitle.setText(title);
  imgDot.getDrawable().setColorFilter(ContextCompat.getColor(getActivity(), dotColor), Mode.SRC_ATOP);
  ViewCompat.setTransitionName(tvTitle, getResources().getString(R.string.transition_tag_title_indexed, fromPosition));
  ViewCompat.setTransitionName(imgDot, getResources().getString(R.string.transition_tag_dot_indexed, fromPosition));
  recyclerView.setHasFixedSize(true);
  recyclerView.setLayoutManager(new GridLayoutManager(view.getContext(), 2));
  recyclerView.setAdapter(new CityGridAdapter(LayoutInflater.from(view.getContext()), CITY_MODELS));
}

代码示例来源:origin: chrisbanes/PhotoView

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_transition);
  RecyclerView list = findViewById(R.id.list);
  list.setLayoutManager(new GridLayoutManager(this, 2));
  ImageAdapter imageAdapter = new ImageAdapter(new ImageAdapter.Listener() {
    @Override
    public void onImageClicked(View view) {
      transition(view);
    }
  });
  list.setAdapter(imageAdapter);
}

代码示例来源:origin: ybq/Android-SpinKit

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
  GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 4);
  layoutManager.setOrientation(RecyclerView.VERTICAL);
  recyclerView.setLayoutManager(layoutManager);
  recyclerView.setAdapter(new RecyclerView.Adapter<Holder>() {
    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
      @SuppressLint("InflateParams") View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list, null);
      return new Holder(view);
    }
    @Override
    public void onBindViewHolder(Holder holder, int position) {
      holder.bind(position);
    }
    @Override
    public int getItemCount() {
      return Style.values().length;
    }
  });
}

代码示例来源:origin: ZieIony/Carbon

private void updateRecycler() {
    if (menu == null)
      return;

    recycler.setLayoutManager(style == Style.List ? new LinearLayoutManager(getContext()) : new GridLayoutManager(getContext(), 3));

    ArrayList<Serializable> items = new ArrayList<>();
    items.addAll(menu.getVisibleItems());
    if (style == Style.List) {
      for (int i = 0; i < items.size() - 1; i++) {
        if (((android.view.MenuItem) items.get(i)).getGroupId() != ((android.view.MenuItem) items.get(i + 1)).getGroupId())
          items.add(++i, new DividerItem());
      }
      items.add(new PaddingItem(getResources().getDimensionPixelSize(R.dimen.carbon_paddingHalf)));
    }

    RowListAdapter<Serializable> adapter = new RowListAdapter<>(MenuItem.class, style == Style.List ? BottomSheetRow::new : BottomSheetCell::new);
    adapter.addFactory(PaddingItem.class, PaddingRow::new);
    adapter.addFactory(DividerItem.class, DividerRow::new);
    adapter.setItems(items);

    recycler.setAdapter(adapter);
  }
}

代码示例来源:origin: alexvasilkov/GestureViews

/**
 * Initializing grid view (RecyclerView) and endless loading.
 */
private void initGrid() {
  // Setting up images grid
  final int cols = getResources().getInteger(R.integer.images_grid_columns);
  views.grid.setLayoutManager(new GridLayoutManager(this, cols));
  gridAdapter = new PhotoListAdapter(this);
  gridAdapter.setLoadingOffset(PAGE_SIZE / 2);
  gridAdapter.setCallbacks(new EndlessRecyclerAdapter.LoaderCallbacks() {
    @Override
    public boolean canLoadNextItems() {
      return gridAdapter.canLoadNext();
    }
    @Override
    public void loadNextItems() {
      // We should either load all items that were loaded before state save / restore,
      // or next page if we already loaded all previously shown items
      int count = Math.max(savedPhotoCount, gridAdapter.getCount() + PAGE_SIZE);
      Events.create(FlickrApi.LOAD_IMAGES_EVENT).param(count).post();
    }
  });
  views.grid.setAdapter(gridAdapter);
}

代码示例来源:origin: mikepenz/Android-Iconics

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  // Init and Setup RecyclerView
  RecyclerView recyclerView = view.findViewById(R.id.list);
  recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
  recyclerView.addItemDecoration(new SpaceItemDecoration());
  //animator not yet working
  recyclerView.setItemAnimator(new DefaultItemAnimator());
  mAdapter = new FastItemAdapter<>();
  configAdapter();
  recyclerView.setAdapter(mAdapter);
  if (getArguments() != null) {
    String fontName = getArguments().getString(FONT_NAME);
    for (ITypeface iTypeface : Iconics.getRegisteredFonts(getActivity())) {
      if (iTypeface.getFontName().equalsIgnoreCase(fontName)) {
        if (iTypeface.getIcons() != null) {
          for (String icon : iTypeface.getIcons()) {
            mIcons.add(new IconItem(icon));
          }
          mAdapter.set(mIcons);
          break;
        }
      }
    }
  }
  //filter if a search param was provided
  onSearch(mSearch);
}

代码示例来源:origin: mikepenz/FastAdapter

GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);

代码示例来源:origin: mikepenz/FastAdapter

adapter.loadAds("76a3fefaced247959582d2d2df6f4757");
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 1));
mRecyclerView.setAdapter(adapter);

代码示例来源:origin: mikepenz/FastAdapter

materialScrollBar.addIndicator(new CustomIndicator(this), true);
rv.setLayoutManager(new GridLayoutManager(this, 3));
rv.setItemAnimator(new SlideDownAlphaAnimator());

代码示例来源:origin: mikepenz/FastAdapter

GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
  @Override

代码示例来源:origin: mikepenz/FastAdapter

} else {
  rv.setLayoutManager(new GridLayoutManager(this, columns));

代码示例来源:origin: lisawray/groupie

groupAdapter.setSpanCount(12);
populateAdapter();
layoutManager = new GridLayoutManager(this, groupAdapter.getSpanCount());
layoutManager.setSpanSizeLookup(groupAdapter.getSpanSizeLookup());

代码示例来源:origin: nickbutcher/plaid

layoutManager = new GridLayoutManager(this, columns);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
  @Override

代码示例来源:origin: pranavpandey/dynamic-support

/**
 * @return The {@link GridLayoutManager} object for a given context.
 *
 * @param context The context to instantiate layout manager.
 * @param count The column count for the grid layout.
 */
public static GridLayoutManager getGridLayoutManager(
    @NonNull Context context, int count) {
  return new GridLayoutManager(context, count);
}

代码示例来源:origin: contentful/gallery-app-android

private void createLayoutManager() {
 layoutManager = new GridLayoutManager(this, GRID_SPAN_COUNT);
 layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
  @Override public int getSpanSize(int position) {
   return adapter.isSection(position) ? GRID_SPAN_COUNT : 1;
  }
 });
}

代码示例来源:origin: MCMrARM/revolution-irc

private View buildDialogView() {
  View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_color_picker, null);
  RecyclerView recyclerView = view.findViewById(R.id.items);
  recyclerView.setLayoutManager(new GridLayoutManager(mContext, 4));
  recyclerView.setAdapter(new ColorListAdapter(this));
  ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
  return view;
}

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

/**
 * Set item size, column size base on the screen orientation
 */
public void changeOrientation(int orientation) {
  imageColumns = orientation == Configuration.ORIENTATION_PORTRAIT ? 3 : 5;
  folderColumns = orientation == Configuration.ORIENTATION_PORTRAIT ? 2 : 4;
  int columns = isShowingFolder ? folderColumns : imageColumns;
  layoutManager = new GridLayoutManager(context, columns);
  recyclerView.setLayoutManager(layoutManager);
  recyclerView.setHasFixedSize(true);
  setItemDecoration(columns);
}

代码示例来源:origin: davideas/FlipView

private void initializeRecyclerView() {
  FlipViewAdapter adapter = new FlipViewAdapter(ITEMS);
  RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
  recyclerView.setLayoutManager(new GridLayoutManager(this, ITEMS / 3));
  recyclerView.setHasFixedSize(true);
  recyclerView.setAdapter(adapter);
}

代码示例来源:origin: turing-tech/MaterialScrollBar

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_others);
  RecyclerView recyclerView = ((RecyclerView)findViewById(R.id.recyclerView));
  recyclerView.setAdapter(new IconAdapter(this));
  recyclerView.setLayoutManager(new GridLayoutManager(this, 4));
  ((TouchScrollBar) findViewById(R.id.touchScrollBar)).setIndicator(new CustomIndicator(this), true);
}

相关文章