當前位置: 首頁>>代碼示例>>Java>>正文


Java GridLayoutManager.setOrientation方法代碼示例

本文整理匯總了Java中android.support.v7.widget.GridLayoutManager.setOrientation方法的典型用法代碼示例。如果您正苦於以下問題:Java GridLayoutManager.setOrientation方法的具體用法?Java GridLayoutManager.setOrientation怎麽用?Java GridLayoutManager.setOrientation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v7.widget.GridLayoutManager的用法示例。


在下文中一共展示了GridLayoutManager.setOrientation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initRecyclerView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
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);
}
 
開發者ID:WeDevelopTeam,項目名稱:HeroVideo-master,代碼行數:21,代碼來源:HomeLiveFragment.java

示例2: setLayoutManger

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
public SmartRecycleView setLayoutManger(LayoutManagerType layoutManagerType, int orientation, int spanCout) {
    RecyclerView.LayoutManager layoutManager = null;
    if (layoutManagerType == LayoutManagerType.LINEAR_LAYOUT) {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        linearLayoutManager.setOrientation(orientation);
        layoutManager = linearLayoutManager;
    } else if (layoutManagerType == LayoutManagerType.GRID_LAYOUT) {
        GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, spanCout);
        gridLayoutManager.setOrientation(orientation);
        layoutManager = gridLayoutManager;
    } else if (layoutManagerType == LayoutManagerType.STAGGER_LAYOUT) {
        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(spanCout, orientation);
        layoutManager = staggeredGridLayoutManager;
    }
    mRecyclerView.setLayoutManager(layoutManager);
    return this;
}
 
開發者ID:GaoGersy,項目名稱:AutoRecycleView,代碼行數:18,代碼來源:SmartRecycleView.java

示例3: initRecyclerView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
@Override
public void initRecyclerView() {

  mLiveAppIndexAdapter = new LiveAppIndexAdapter(LiveAppIndexActivity.this);
  mRecyclerView.setAdapter(mLiveAppIndexAdapter);
  GridLayoutManager layout = new GridLayoutManager(LiveAppIndexActivity.this, 12);
  layout.setOrientation(LinearLayoutManager.VERTICAL);
  layout.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

    @Override
    public int getSpanSize(int position) {

      return mLiveAppIndexAdapter.getSpanSize(position);
    }
  });

  mRecyclerView.setLayoutManager(layout);
}
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:19,代碼來源:LiveAppIndexActivity.java

示例4: initRecyclerView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
@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);
}
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:19,代碼來源:HomeLiveFragment.java

示例5: setGView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
private void setGView() {
    GridLayoutManager manager = new GridLayoutManager(mContext, mNunColumns);
    if (mRecyclerViewStyle == RecyclerViewStyle.HorizontalGridView) {
        manager.setOrientation(GridLayoutManager.HORIZONTAL);
    } else {
        manager.setOrientation(GridLayoutManager.VERTICAL);
    }
    if (mAdapter != null) {
        if (mAdapter.isAddFoot() || mAdapter.isAddHead()) {
            //將gridview的頭部或者尾部設置成
            manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
                @Override
                public int getSpanSize(int position) {
                    if (position < mAdapter.getmHeaderArraySize()||
                            position>=mAdapter.getmHeaderArraySize()+mAdapter.getmDatas().size()) {
                        return mNunColumns;
                    } else {
                        return 1;
                    }
                }
            });
        }
    }
    mRecyclerView.setLayoutManager(manager);
}
 
開發者ID:liusmallpig,項目名稱:LowRecyclerView,代碼行數:26,代碼來源:RecyclerViewUtils.java

示例6: onCreateView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_movies_watch_later, container, false);
    ButterKnife.bind(this, view);

    realm = Realm.getDefaultInstance();

    GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 2);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);

    if (Build.VERSION.SDK_INT >= 21) {
        getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
    }

    rvMoviesWatchLater.setLayoutManager(layoutManager);

    rvMoviesWatchLater.setAdapter(new MoviesWatchLaterAdapter(realm.where(Movie.class)
            .equalTo("isWatchLater", true).findAllAsync(), true, this));

    return view;
}
 
開發者ID:hsm59,項目名稱:WatchIt,代碼行數:23,代碼來源:MoviesWatchLaterFragment.java

示例7: onCreateView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
@Override
public View onCreateView(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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:HorizontalGalleryFragment.java

示例8: onCreate

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);

    SimpleAdapter adapter = new SimpleAdapter(this);
    GridLayoutManager manager = new GridLayoutManager(this, 3);
    manager.setOrientation(OrientationHelper.VERTICAL);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_recyclerview);
    recyclerView.setLayoutManager(manager);
    recyclerView.setAdapter(adapter);
    recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this).build());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:SimpleGridActivity.java

示例9: setGridLayout

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
/**
 * GridLayoutManager
 */

public void setGridLayout(int spanCount) {

    GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, spanCount);
    gridLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(gridLayoutManager);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:PullLoadMoreRecyclerView.java

示例10: onCreateView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
@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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:HorizontalGalleryFragment.java

示例11: initializeGridRecyclerView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
private void initializeGridRecyclerView(final View layout) {
  // Get RecyclerView
  mRecyclerView = UI.findViewById(layout, R.id.recycler_view);
  // Choose the LayoutManager
  GridLayoutManager layoutManager = new GridLayoutManager(getContext(), mConfig.gridSpanCount);
  layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
  layoutManager.scrollToPosition(0);
  mRecyclerView.setLayoutManager(layoutManager);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:MainFragment.java

示例12: initRecyclerView

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
@Override
protected void initRecyclerView() {
    mLiveAppIndexAdapter = new LiveAppIndexAdapter(getActivity());
    mRecyclerView.setAdapter(mLiveAppIndexAdapter);
    GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 12);
    gridLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return mLiveAppIndexAdapter.getSpanSize(position);
        }
    });
    mRecyclerView.setLayoutManager(gridLayoutManager);
}
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:15,代碼來源:HomeLiveFragment.java

示例13: initEvents

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
@Override
protected void initEvents() {

    mToolbar.setTitle("Bookshelf");
    spanCount = getResources().getInteger(R.integer.gallery_span_count);
    mBookshelfPresenter = new BookshelfPresenterImpl(this);


    /*mSwipeRefreshLayout.setColorSchemeResources(R.color.recycler_color1, R.color.recycler_color2,
            R.color.recycler_color3, R.color.recycler_color4);*/

    mLayoutManager = new GridLayoutManager(getActivity(), spanCount);
    mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return mBookshelfAdapter.getItemColumnSpan(position);
        }
    });
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(mLayoutManager);

    mBookshelfs = new ArrayList<>();
    mBookshelfAdapter = new BookshelfAdapter(mBookshelfs, getActivity(), spanCount);
    mBookshelfAdapter.setOnAdjustmentConfirmListener(this);
    mBookshelfAdapter.setOnDeleteConfirmListener(this);
    mBookshelfAdapter.setOnBookshelfClickListener((BookshelfAdapter.OnBookshelfClickListener) getActivity());
    mRecyclerView.setAdapter(mBookshelfAdapter);

    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    final int space = DensityUtils.dp2px(getActivity(), 4);
    mRecyclerView.addItemDecoration(new StaggeredGridDecoration(space, space, space, space, spanCount));
    onRefresh();
}
 
開發者ID:chengkun123,項目名稱:ReadMark,代碼行數:34,代碼來源:BookshelfFragment.java

示例14: onActivityCreated

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    LogUtils.i(TAG, "onActivityCreated");

    mAdapter = new AlbumsAdapter(mContext, new ArrayList<Album>());

    GridLayoutManager layoutManager = new GridLayoutManager(mContext, 2);
    layoutManager.setOrientation(GridLayoutManager.VERTICAL);

    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setAdapter(mAdapter);
}
 
開發者ID:komamj,項目名稱:KomaMusic,代碼行數:16,代碼來源:AlbumsFragment.java

示例15: onCreate

import android.support.v7.widget.GridLayoutManager; //導入方法依賴的package包/類
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    setToolbar(false);
    goToSplashActivity();

    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    recyclerView.setHasFixedSize(true);
    final GridLayoutManager llm = new GridLayoutManager(this, 2);
    llm.setOrientation(GridLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(llm);

    final ArrayList<CardViewModel> data = new ArrayList<>();
    for (int i = 0; i < getStringArrayByResources(this, R.array.card_titles).length; i++) {
        data.add(new CardViewModel(
                getStringArrayByResources(this, R.array.card_titles)[i],
                getDrawableArrayByResources(this, R.array.card_icons).getResourceId(i, -1),
                getStringArrayByResources(this, R.array.card_activities)[i]
        ));
    }

    final View.OnClickListener onClickListener = new CardOnClickListener(this, recyclerView);
    final RecyclerView.Adapter<RecyclerViewAdapter.RecyclerViewHolder> adapter = new RecyclerViewAdapter(data, onClickListener);
    recyclerView.setAdapter(adapter);

}
 
開發者ID:SofiaRosetti,項目名稱:S3-16-d-rescue,代碼行數:29,代碼來源:MainActivity.java


注:本文中的android.support.v7.widget.GridLayoutManager.setOrientation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。