Java Code Examples for android.support.v7.widget.RecyclerView#addItemDecoration()
The following examples show how to use
android.support.v7.widget.RecyclerView#addItemDecoration() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageFragment.java From xmpp with Apache License 2.0 | 6 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (view == null) { user = SaveUserUtil.loadAccount(getActivity()).getUser(); Log.i("message", "user=" + user); view = inflater.inflate(R.layout.fragment_message, container, false); ButterKnife.bind(this, view); rv = (RecyclerView) view.findViewById(R.id.fragment_messgae_recyclerview); rv.setLayoutManager(new LinearLayoutManager(getActivity()));//设置排列方式 rv.addItemDecoration(new RecyclerViewDividerItemDecoration(getActivity(), RecyclerViewDividerItemDecoration.VERTICAL_LIST)); initialData(); } return view; }
Example 2
Source File: MainActivity.java From rv-adapter-endless with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final RecyclerView rv = (RecyclerView) findViewById(R.id.recycler_view); rv.setLayoutManager(new LinearLayoutManager(this)); rv.setHasFixedSize(true); adapter = new SimpleStringAdapter(null); endlessRecyclerViewAdapter = new EndlessRecyclerViewAdapter(adapter, this); // Optional endlessRecyclerViewAdapter.setPendingViewId(R.layout.custom_pending_view); rv.setAdapter(endlessRecyclerViewAdapter); rv.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST)); }
Example 3
Source File: AppListFragment.java From AppPlus with MIT License | 6 votes |
private void setupRecyclerView(View rootView) { mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview); LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity()); mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST)); //every item's height is fix so use this method //RecyclerView can perform several optimizations mRecyclerView.setHasFixedSize(true); mAdapter = new AppInfoListAdapter(getActivity(), Utils.isBriefMode()); mAdapter.setClickPopupMenuItem(this); mAdapter.setClickListItem(this); SlideInBottomAnimationAdapter slideInLeftAdapter = new SlideInBottomAnimationAdapter(mAdapter); slideInLeftAdapter.setDuration(300); slideInLeftAdapter.setInterpolator(new AccelerateDecelerateInterpolator()); mRecyclerView.setAdapter(slideInLeftAdapter); }
Example 4
Source File: BluetoothTestDialogFragment.java From Printer with Apache License 2.0 | 6 votes |
@SuppressWarnings("all") IPTestDialog(Context context, int type, int width, int height, String qr) { super(context); this.type = type; setContentView(R.layout.dlg_printer_bluetooth); RecyclerView rvBonded = (RecyclerView) findViewById(R.id.printer_rv_bonded); rvBonded.setLayoutManager(new LinearLayoutManager(getContext())); rvBonded.addItemDecoration(new DividerItemDecoration( ContextCompat.getDrawable(getContext(), R.drawable.divider_printer), DividerItemDecoration.VERTICAL_LIST)); rvBonded.setAdapter(bondedAdapter); updateAdapter(); tvState = (TextView) findViewById(R.id.printer_tv_state); btnPrint = (Button) findViewById(R.id.printer_btn_test_print); btnPrint.setOnClickListener(this); setEditable(true); maker = new TestPrintDataMaker(context, qr, width, height); }
Example 5
Source File: PicassoActivity.java From AndroidDemo with MIT License | 6 votes |
@Override protected void init() { recyclerView = (RecyclerView) findViewById(R.id.recyclerView); ll_other = (LinearLayout) findViewById(R.id.ll_other); cb_cache = (CheckBox) findViewById(R.id.cb_cache); cb_disk = (CheckBox) findViewById(R.id.cb_disk); cb_transformation = (CheckBox) findViewById(R.id.cb_transformation); imageView = (ImageView) findViewById(R.id.imageView); recyclerView.setLayoutManager(new GridLayoutManager(this, 4)); recyclerView.addItemDecoration(new DividerItemDecoration(this)); pictureAdapter = new PictureAdapter(this, data); recyclerView.setAdapter(pictureAdapter); if (picturePresenter.checkPermission()) { picturePresenter.onLoad(); } }
Example 6
Source File: PostFrag.java From httplite with Apache License 2.0 | 6 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.frag_get,container,false); mRecyclerView = (RecyclerView) view.findViewById(R.id.file_list); mPathTv = (TextView) view.findViewById(R.id.tv_request_path); mAdapter = new FileAdapter(null,this); mRecyclerView.setAdapter(mAdapter); mRecyclerView.addItemDecoration(new RecycleViewDivider(getContext(), LinearLayoutManager.HORIZONTAL)); mBackUpBtn = (Button) view.findViewById(R.id.btn_back_up); mBackUpBtn.setOnClickListener(this); if(basePath==null){ File file = getActivity().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS); if(file==null){ file = getActivity().getCacheDir(); } basePath = file.getAbsolutePath(); } if(currentPath==null){ currentPath = basePath; } mHttpLite = App.httpLite(getActivity()); loadFiles(currentPath); return view; }
Example 7
Source File: DisplayManager.java From SoloPi with Apache License 2.0 | 6 votes |
/** * 提供主界面 * @param context * @return */ private View provideMainView(Context context) { if (runningMode == DisplayProvider.RECORDING_MODE) { return null; } floatWinList = (RecyclerView) LayoutInflater.from(context).inflate(R.layout.display_main_layout, null); floatWinList.setLayoutManager(new LinearLayoutManager(context)); floatWinList.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return false; } }); floatWinAdapter = new FloatWinAdapter(context, this, currentDisplayInfo); floatWinList.setAdapter(floatWinAdapter); // 添加分割线 floatWinList.addItemDecoration(new RecycleViewDivider(context, LinearLayoutManager.HORIZONTAL, 1, context.getResources().getColor(R.color.divider_color))); return floatWinList; }
Example 8
Source File: HongKongIslandFragment.java From FaceT with Mozilla Public License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment view = inflater.inflate(R.layout.fragment_hong_kong_island, container, false); recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view_hkIsland); mAdapter = new ShopsAdapter(shopList, getActivity()); RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(view.getContext()); recyclerView.setLayoutManager(mLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), LinearLayoutManager.VERTICAL)); recyclerView.setAdapter(mAdapter); mAdapter.notifyDataSetChanged(); return view; }
Example 9
Source File: VideoActivity.java From Album with Apache License 2.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_album); mToolbar = findViewById(R.id.toolbar); setSupportActionBar(mToolbar); mTvMessage = findViewById(R.id.tv_message); RecyclerView recyclerView = findViewById(R.id.recycler_view); recyclerView.setLayoutManager(new GridLayoutManager(this, 3)); Divider divider = new Api21ItemDivider(Color.TRANSPARENT, 10, 10); recyclerView.addItemDecoration(divider); mAdapter = new Adapter(this, new OnItemClickListener() { @Override public void onItemClick(View view, int position) { previewVideo(position); } }); recyclerView.setAdapter(mAdapter); }
Example 10
Source File: SliceTestActivity.java From incubator-weex-playground with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { WXSDKEngine.registerModule("searchEvent", SearchModule.class); } catch (WXException e) { e.printStackTrace(); } setContentView(R.layout.activity_slice_test); mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view); mReportTextView = (TextView) findViewById(R.id.report_text); mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); mAdapter = new WXInstanceAdapter(); mRecyclerView.setAdapter(mAdapter); }
Example 11
Source File: AbstractFilePickerFragment.java From NoNonsense-FilePicker with Mozilla Public License 2.0 | 5 votes |
/** * Checks if a divider drawable has been defined in the current theme. If it has, will apply * an item decoration with the divider. If no divider has been specified, then does nothing. */ protected void configureItemDecoration(@NonNull LayoutInflater inflater, @NonNull RecyclerView recyclerView) { final TypedArray attributes = getActivity().obtainStyledAttributes(new int[]{R.attr.nnf_list_item_divider}); Drawable divider = attributes.getDrawable(0); attributes.recycle(); if (divider != null) { recyclerView.addItemDecoration(new DividerItemDecoration(divider)); } }
Example 12
Source File: TransitionAnimationActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
private void initRecyclerView() { RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv_share_elements); recyclerView.setFocusable(false); recyclerView.setLayoutManager(new GridLayoutManager(this, 2)); recyclerView.setNestedScrollingEnabled(false); recyclerView.addItemDecoration(new GridSpacingItemDecoration(2, 5, false)); recyclerView.setAdapter(new MyRecyclerViewAdapter(this)); }
Example 13
Source File: HeaderFooterActivity.java From LightAdapter with Apache License 2.0 | 5 votes |
private void init() { setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); recyclerView = (RecyclerView) findViewById(R.id.recyclerView); recyclerView.addItemDecoration(new DefaultItemDecoration( ContextCompat.getColor(this, R.color.white), ContextCompat.getColor(this, R.color.divider), getResources().getDimensionPixelSize(R.dimen.zero))); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setEnabled(false); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setAdapter(adapter = new LightAdapter()); }
Example 14
Source File: EventListActivity.java From android-samples with Apache License 2.0 | 5 votes |
private void setRecyclerView() { RecyclerView eventList = (RecyclerView) findViewById(R.id.event_list); eventList.setItemAnimator(new DefaultItemAnimator()); eventList.setLayoutManager(new LinearLayoutManager(this)); RecyclerView.ItemDecoration dividerItemDecoration = new DividerItemDecorator(ContextCompat.getDrawable(this, R.drawable.line_divider)); eventList.addItemDecoration(dividerItemDecoration); eventList.setAdapter(new RecyclerViewAdapter(getCalenderEvents())); }
Example 15
Source File: SelectCheckoutActivity.java From px-android with MIT License | 5 votes |
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_select_checkout); progress = findViewById(R.id.mpsdkProgressLayout); final RecyclerView recyclerView = findViewById(R.id.recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(this)); final DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL); recyclerView.setAdapter(new SelectionAdapter(getOptions(), this::startCheckout)); recyclerView.addItemDecoration(dividerItemDecoration); }
Example 16
Source File: RecyclerViewFragment.java From AutoLayout with Apache License 2.0 | 5 votes |
private void initView() { mContext = getActivity(); mRecyclerView = (RecyclerView) mView.findViewById(R.id.id_recyclerview); mList = new ArrayList<String>(); for (int i = 0; i < 50; i++) { mList.add(i + ""); } mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); mRecyclerView.setAdapter(new MyAdapter()); mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST)); }
Example 17
Source File: MainActivity.java From GraphView with Apache License 2.0 | 5 votes |
private void setupRecyclerView() { RecyclerView graphs = findViewById(R.id.graphs); graphs.setLayoutManager(new LinearLayoutManager(this)); graphs.setAdapter(new GraphListAdapter()); DividerItemDecoration decoration = new DividerItemDecoration(getApplicationContext(), VERTICAL); graphs.addItemDecoration(decoration); }
Example 18
Source File: ProfileAdapter.java From ForPDA with GNU General Public License v3.0 | 5 votes |
InfosHolder(View itemView) { super(itemView); title = (TextView) itemView.findViewById(R.id.profile_sub_title); list = (RecyclerView) itemView.findViewById(R.id.profile_sub_list); list.setHasFixedSize(true); list.setLayoutManager(new LinearLayoutManager(list.getContext())); list.setNestedScrollingEnabled(false); list.addItemDecoration(new BrandFragment.SpacingItemDecoration(App.px16, true)); adapter = new InfoAdapter(); list.setAdapter(adapter); title.setText(R.string.profile_title_information); }
Example 19
Source File: DashboardFragment.java From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { mViewSwitcher = (ViewSwitcher) view; mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); final int spanCount = getResources().getInteger(R.integer.column_nums); mAdapter = new DashboardItemAdapter(getActivity(), getAccessFromBundle(getArguments()), spanCount, this); GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), spanCount); gridLayoutManager.setOrientation(GridLayoutManager.VERTICAL); gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return mAdapter.getSpanSize(position); } }); mRecyclerView.setLayoutManager(gridLayoutManager); mRecyclerView.setItemAnimator(new DefaultItemAnimator()); mRecyclerView.addItemDecoration(new GridDividerDecoration(getActivity() .getApplicationContext())); mRecyclerView.setAdapter(mAdapter); }
Example 20
Source File: Test3Fragment.java From YCStateLayout with Apache License 2.0 | 5 votes |
@Override public void initView(View view) { RecyclerView recyclerView = view.findViewById(R.id.recycleView); GridLayoutManager layoutManager = new GridLayoutManager(activity, 2); layoutManager.setOrientation(OrientationHelper.VERTICAL); recyclerView.setLayoutManager(layoutManager); recyclerView.addItemDecoration(new DividerItemDecoration(activity, DividerItemDecoration.VERTICAL)); recyclerView.setItemAnimator(new DefaultItemAnimator()); adapter = new RecyclerAdapter(initData()); recyclerView.setAdapter(adapter); }