当前位置: 首页>>代码示例>>Java>>正文


Java LinearLayoutManager类代码示例

本文整理汇总了Java中android.support.v7.widget.LinearLayoutManager的典型用法代码示例。如果您正苦于以下问题:Java LinearLayoutManager类的具体用法?Java LinearLayoutManager怎么用?Java LinearLayoutManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LinearLayoutManager类属于android.support.v7.widget包,在下文中一共展示了LinearLayoutManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateView

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_journal_list, container, false);

    // Set the adapter
    if (view instanceof RecyclerView) {
        FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
        FirebaseAuth auth = FirebaseAuth.getInstance();
        FirebaseUser user = auth.getCurrentUser();
        DatabaseReference userRef = dbRef.getReference(user.getUid());
        userRef.addChildEventListener (chEvListener);
        userRef.addValueEventListener(valEvListener);
        Context context = view.getContext();
        RecyclerView recyclerView = (RecyclerView) view;
        if (mColumnCount <= 1) {
            recyclerView.setLayoutManager(new LinearLayoutManager(context));
        } else {
            recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
        }
        adapter = new JournalAdapter(allTrips, mListener);
        recyclerView.setAdapter(adapter);
    }
    return view;
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:26,代码来源:JournalFragment.java

示例2: getItemWidth

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
/**
 * 计算每个Item的宽度
 */
public int getItemWidth() {
    final LayoutManager layoutManager = getLayoutManager();
    int itemWidth = 0;
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final int spanCount = gridLayoutManager.getSpanCount();
        if (gridLayoutManager.getOrientation() == LinearLayoutManager.HORIZONTAL) {
            itemWidth = getRawWidth() / (mItemCount / spanCount);
        } else {
            itemWidth = getRawWidth() / spanCount;
        }

    } else if (layoutManager instanceof LinearLayoutManager) {
        final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
        if (linearLayoutManager.getOrientation() == LinearLayoutManager.HORIZONTAL) {
            itemWidth = getRawWidth() / mItemCount;
        } else {
            itemWidth = getRawWidth();
        }
    }

    return itemWidth;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:27,代码来源:RecyclerViewPager.java

示例3: init

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
private void init(){
    for (int i = 0 ;i < themeType.length;i++){
        ThemeInfo info = new ThemeInfo();
        info.setName(themeType[i]);
        info.setColor(colors[i]);
        info.setSelect((selectTheme == i) ? true : false);
        if (i == themeType.length-1){
            info.setBackground(R.color.nightBg);
        }else {
            info.setBackground(R.color.colorWhite);
        }
        themeInfoList.add(info);
    }
    recyclerView = (RecyclerView)findViewById(R.id.theme_rv);
    adapter = new ThemeAdapter();
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setAdapter(adapter);

}
 
开发者ID:lijunyandev,项目名称:MeetMusic,代码行数:22,代码来源:ThemeActivity.java

示例4: initData

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
@Override
protected void initData() {
    List<ItemModel> items = new ArrayList<>();
    fillData(items);

    adapter = new MainAdapter(items);
    adapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
    adapter.isFirstOnly(false);
    adapter.setOnLoadMoreListener(this);

    refreshLayout.setColorSchemeColors(Color.RED, Color.BLUE, Color.GREEN);
    refreshLayout.setOnRefreshListener(this);

    recyclerView.setLayoutManager(new LinearLayoutManager(context));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addItemDecoration(new DividerItemDecoration(context, LinearLayoutManager.VERTICAL));

    recyclerView.setAdapter(adapter);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:MainFragment.java

示例5: onCreate

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    RecyclerView rcViewList = (RecyclerView) findViewById(R.id.rc_item);
    rcViewList.setAdapter(new ItemAdapter(generateFakeItems(), new OnItemClickListener() {
        @Override
        public void onItemClick(int position) {
            startActivity(new Intent(MainActivity.this, FragmentPagerActivity.class));
        }
    }));
    rcViewList.setLayoutManager(new LinearLayoutManager(this));
    rcViewList.addItemDecoration(new DividerItemDecoration(this,
                                                           DividerItemDecoration.VERTICAL));
}
 
开发者ID:interactiveservices,项目名称:adapters-android,代码行数:17,代码来源:MainActivity.java

示例6: initView

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
private void initView(List<String> list) {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setHasFixedSize(true);
    linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setSmoothScrollbarEnabled(true);
    recyclerView.setLayoutManager(linearLayoutManager);
    ListRecyclerAdapter adapter = new ListRecyclerAdapter(list);
    recyclerView.setAdapter(adapter);

    FAB = (FloatingActionButton) findViewById(R.id.fab);
    FAB.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            linearLayoutManager.scrollToPosition(0);
            hideFAB();
        }
    });
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:23,代码来源:BackTopActivity.java

示例7: setVideoRelated

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
private void setVideoRelated() {

    List<VideoDetailsInfo.DataBean.RelatesBean> relates = mVideoDetailsInfo.getRelates();
    if (relates == null) {
      mVideoRelatedLayout.setVisibility(View.GONE);
      return;
    }
    VideoRelatedAdapter mVideoRelatedAdapter = new VideoRelatedAdapter(mRecyclerView, relates);
    mRecyclerView.setHasFixedSize(false);
    mRecyclerView.setNestedScrollingEnabled(false);
    mRecyclerView.setLayoutManager(
        new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, true));
    mRecyclerView.setAdapter(mVideoRelatedAdapter);
    mVideoRelatedAdapter.setOnItemClickListener(
        (position, holder) -> VideoDetailsActivity.launch(getActivity(),
            relates.get(position).getAid(), relates.get(position).getPic()));
  }
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:18,代码来源:VideoIntroductionFragment.java

示例8: computeAlignOffset

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
@Override
public int computeAlignOffset(int offset, boolean isLayoutEnd, boolean useAnchor,
        LayoutManagerHelper helper) {
    //Log.d(TAG,
    //    "range " + getRange() + " offset " + offset + " isLayoutEnd " + isLayoutEnd + " useAnchor " + useAnchor
    //        + " helper " + this.hashCode());
    final boolean layoutInVertical = helper.getOrientation() == LinearLayoutManager.VERTICAL;

    if (useAnchor) {
        return 0;
    }
    if (isLayoutEnd) {
        if (offset == getItemCount() - 1) {
            return layoutInVertical ? mMarginBottom + mPaddingBottom : mMarginRight + mPaddingRight;
        }
    } else {
        if (offset == 0) {
            return layoutInVertical ? -mMarginTop - mPaddingTop : -mMarginLeft - mPaddingLeft;
        }
    }
    return 0;
}
 
开发者ID:alibaba,项目名称:vlayout,代码行数:23,代码来源:OnePlusNLayoutHelper.java

示例9: onCreate

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_heroes_list);
    context = this;

    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context,
            LinearLayoutManager.VERTICAL, false);
    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context,
            linearLayoutManager.getOrientation());
    binding.rvHeroes.setLayoutManager(linearLayoutManager);
    binding.rvHeroes.addItemDecoration(dividerItemDecoration);
    binding.rvHeroes.setAdapter(heroesAdapter);
    binding.fastScroll.setRecyclerView(binding.rvHeroes);

    heroesAdapter.setOnClickListener(position -> presenter.onSuperHeroClicked(position));

    binding.btnTryAgain.setOnClickListener(v -> presenter.getSuperHeroes());

    binding.btnTryAgain.performClick();
}
 
开发者ID:cyrilpillai,项目名称:SuperNatives,代码行数:23,代码来源:HeroesListActivity.java

示例10: setUpRecyclerView

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
private void setUpRecyclerView() {

        if(mTask.getAttachments().size() > 0) {
            mAttachmentsSubtitle.setVisibility(View.VISIBLE);

            mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
            mAdapter = new AttachmentAdapter(this, mTask.getAttachments(), true);
            mAdapter.setAttachmentDataUpdatedListener(new AttachmentAdapter.AttachmentDataUpdatedListener() {
                @Override
                public void onAttachmentDataUpdated() {
                    mTaskDataUpdated = true;
                }
            });
            DividerItemDecoration itemDecoration = new DividerItemDecoration(this, mLayoutManager.getOrientation());
            itemDecoration.setDrawable(ContextCompat.getDrawable(this, R.drawable.item_decoration_half_line));
            mRecyclerView.addItemDecoration(itemDecoration);
            mRecyclerView.setNestedScrollingEnabled(false);

            mRecyclerView.setLayoutManager(mLayoutManager);
            mRecyclerView.setAdapter(mAdapter);
        }
    }
 
开发者ID:abicelis,项目名称:Remindy,代码行数:23,代码来源:TaskDetailActivity.java

示例11: BounceMenu

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
private BounceMenu(View view, int resId, final MyAdapter myAdapter) {
    parentVG = findParentVG(view);

    rootView = LayoutInflater.from(view.getContext()).inflate(resId,null,false);
    recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
    bounceView = (BounceView) rootView.findViewById(R.id.bounceview);

    recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
    bounceView.setAnimatorListener(new BounceView.BounceAnimatorListener() {
        @Override
        public void showContent() {
            recyclerView.setVisibility(View.VISIBLE);
            recyclerView.setAdapter(myAdapter);
            recyclerView.scheduleLayoutAnimation();
        }
    });
}
 
开发者ID:SingleShu,项目名称:BounceView,代码行数:18,代码来源:BounceMenu.java

示例12: setUpInfo

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
private void setUpInfo(View view) {
    RecyclerView rvInfo = (RecyclerView) view.findViewById(R.id.rv_movie_detail_info);
    ArrayList<ItemInfo> infoItems = new ArrayList<>();
    String overviewValStr = view.getResources().getString(R.string.lorem_ipsum_long);

    infoItems.add(new ItemInfo("Overview", overviewValStr));
    infoItems.add(new ItemInfo("Tagline", "Divided We Fall"));
    infoItems.add(new ItemInfo("Status", "Releases"));
    infoItems.add(new ItemInfo("Budget", "250.000.000"));
    infoItems.add(new ItemInfo("Revenue", "1.153.304.495"));
    infoItems.add(new ItemInfo("Homepage", "http://marvel.com/captainamericapremiere"));

    RecyclerAdapter infoAdapter = new RecyclerAdapter<ItemInfo, MovieInfoViewHolder>(
            R.layout.item_movie_info, ItemInfo.class, infoItems, MovieInfoViewHolder.class) {
        @Override
        protected void bindView(MovieInfoViewHolder holder, ItemInfo model, int position) {
            holder.getLabel().setText(model.getLabel());
            holder.getValue().setText(model.getValue());
        }
    };

    rvInfo.setLayoutManager(new LinearLayoutManager(view.getContext()));
    rvInfo.setAdapter(infoAdapter);
    rvInfo.addItemDecoration(new MovieInfoViewHolder.ItemDecoration());
}
 
开发者ID:ramadani,项目名称:Pilem,代码行数:26,代码来源:MovieInfoFragment.java

示例13: onScrollStateChanged

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
    super.onScrollStateChanged(recyclerView, newState);
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof LinearLayoutManager) {
        LinearLayoutManager linearManager = (LinearLayoutManager) layoutManager;
        int firstItemPosition = linearManager.findFirstVisibleItemPosition();
        if(firstItemPosition == 0 || mContentListAdapter.getItemCount() == 0){
            mRefreshLayout.setEnabled(true);
            CFLog.e("V2MainFragment", "arrive top");
        }
        else{
            mRefreshLayout.setEnabled(false);
        }
    }
}
 
开发者ID:stdnull,项目名称:RunMap,代码行数:17,代码来源:V2MainFragment.java

示例14: setData

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
public void setData(ArrayList<FinancingInfo> data,boolean isRefresh) {
    if (isRefresh){
        mData.clear();
    }
    mData.addAll(data);
    if (null == adapter) {
        manager = new LinearLayoutManager(getActivity());
        mRec.addItemDecoration(new DividerGridItemDecoration(getActivity()));
        adapter = new YearAdapter(mData, getActivity());
        mRec.setAdapter(adapter);
        mRec.setLayoutManager(manager);
    } else {
        adapter.notifyDataSetChanged();

    }
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:17,代码来源:YearDelegate.java

示例15: onCreateView

import android.support.v7.widget.LinearLayoutManager; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_promociones, container, false);
    rvPromociones = (RecyclerView) view.findViewById(R.id.rv_promociones);
    textViewEmptyPromociones = (TextView) view.findViewById(R.id.textview_empty_promociones);

    LinearLayoutManager llm = new LinearLayoutManager(getContext());
    adapter = new RVPromocionAdapter(getContext(), empresa.getPromociones(), empresa);

    rvPromociones.setLayoutManager(llm);
    rvPromociones.setAdapter(adapter);

    if (empresa.getPromociones().isEmpty()) {
        textViewEmptyPromociones.setVisibility(View.VISIBLE);
    }

    return view;
}
 
开发者ID:ur13l,项目名称:Guanajoven,代码行数:20,代码来源:PromocionFragment.java


注:本文中的android.support.v7.widget.LinearLayoutManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。