本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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());
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}