Java Code Examples for androidx.recyclerview.widget.RecyclerView#setAdapter()
The following examples show how to use
androidx.recyclerview.widget.RecyclerView#setAdapter() .
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: SortFragment.java From prayer-times-android with Apache License 2.0 | 6 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle bdl) { View v = inflater.inflate(R.layout.vakit_sort_main, container, false); RecyclerView recyclerMan = v.findViewById(R.id.list); mAdapter = new MyAdapter(); recyclerMan.setAdapter(mAdapter); LinearLayoutManager linLayMan = new LinearLayoutManager(getContext()); recyclerMan.setLayoutManager(linLayMan); recyclerMan.setHasFixedSize(true); ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(); mItemTouchHelper = new ItemTouchHelper(callback); mItemTouchHelper.attachToRecyclerView(recyclerMan); setHasOptionsMenu(true); Times.getTimes().observe(this, mAdapter); mAdapter.onChanged(Times.getTimes()); return v; }
Example 2
Source File: Example1Fragment.java From SectionedRecyclerViewAdapter with MIT License | 6 votes |
@Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_ex1, container, false); sectionedAdapter = new SectionedRecyclerViewAdapter(); final Map<String, List<Contact>> contactsMap = new LoadContactsUseCase().execute(requireContext()); for (final Map.Entry<String, List<Contact>> entry : contactsMap.entrySet()) { if (entry.getValue().size() > 0) { sectionedAdapter.addSection(new ContactsSection(entry.getKey(), entry.getValue(), this)); } } final RecyclerView recyclerView = view.findViewById(R.id.recyclerview); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(sectionedAdapter); return view; }
Example 3
Source File: ShareDialog.java From AndroidProject with Apache License 2.0 | 6 votes |
public Builder(Context context) { super(context); setContentView(R.layout.dialog_share); final List<ShareBean> data = new ArrayList<>(); data.add(new ShareBean(getDrawable(R.drawable.ic_share_wechat), getString(R.string.share_platform_wechat), Platform.WECHAT)); data.add(new ShareBean(getDrawable(R.drawable.ic_share_moment), getString(R.string.share_platform_moment), Platform.CIRCLE)); data.add(new ShareBean(getDrawable(R.drawable.ic_share_qq), getString(R.string.share_platform_qq), Platform.QQ)); data.add(new ShareBean(getDrawable(R.drawable.ic_share_qzone), getString(R.string.share_platform_qzone), Platform.QZONE)); data.add(new ShareBean(getDrawable(R.drawable.ic_share_link), getString(R.string.share_platform_link), null)); mAdapter = new ShareAdapter(context); mAdapter.setData(data); mAdapter.setOnItemClickListener(this); RecyclerView recyclerView = findViewById(R.id.rv_share_list); recyclerView.setLayoutManager(new GridLayoutManager(context, data.size())); recyclerView.setAdapter(mAdapter); mData = new UmengShare.ShareData(context); }
Example 4
Source File: YouTubeNativeFragmentDemo.java From android-inline-youtube-view with Apache License 2.0 | 6 votes |
@Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { RecyclerView view = (RecyclerView) inflater.inflate(R.layout.youtube_native_fragment, container, false); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()); view.setLayoutManager(linearLayoutManager); Bundle arguments = getArguments(); int playerType = arguments.getInt("playerType"); ArrayList<String> videoIds = new ArrayList<>(); videoIds.add("2Vv-BfVoq4g"); videoIds.add("D5drYkLiLI8"); videoIds.add("K0ibBPhiaG0"); videoIds.add("ebXbLfLACGM"); videoIds.add("mWRsgZuwf_8"); YouTubePlayerAdapter youTubePlayerAdapter = new YouTubePlayerAdapter(videoIds, this, playerType); view.setAdapter(youTubePlayerAdapter); return view; }
Example 5
Source File: SecurityActivity.java From green_android with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_onboarding_security); setTitle(""); getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(android.R.color.transparent)); final String[] choices = getResources().getStringArray(R.array.twoFactorChoices); final String[] methods = getResources().getStringArray(R.array.twoFactorMethods); final Integer[] images = { R.drawable.ic_2fa_email, R.drawable.ic_2fa_sms, R.drawable.ic_2fa_call, R.drawable.ic_2fa_google }; if (!isFromOnboarding()) { UI.hide(UI.find(this, R.id.nextButton)); setTitleBack(); } mMethodsAdapter = new ViewAdapter(this, Arrays.asList(methods), Arrays.asList(choices), Arrays.asList(images)); final RecyclerView wordsRecyclerView = UI.find(this, R.id.twoFactorsRecyclerView); wordsRecyclerView.setHasFixedSize(true); wordsRecyclerView.setLayoutManager(new LinearLayoutManager(this)); wordsRecyclerView.setAdapter(mMethodsAdapter); }
Example 6
Source File: ProductGridFragment.java From material-components-android-codelabs with Apache License 2.0 | 5 votes |
@Override public View onCreateView( @NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment with the ProductGrid theme View view = inflater.inflate(R.layout.shr_product_grid_fragment, container, false); // Set up the tool bar setUpToolbar(view); // Set up the RecyclerView RecyclerView recyclerView = view.findViewById(R.id.recycler_view); recyclerView.setHasFixedSize(true); GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2, GridLayoutManager.HORIZONTAL, false); gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return position % 3 == 2 ? 2 : 1; } }); recyclerView.setLayoutManager(gridLayoutManager); StaggeredProductCardRecyclerViewAdapter adapter = new StaggeredProductCardRecyclerViewAdapter( ProductEntry.initProductEntryList(getResources())); recyclerView.setAdapter(adapter); int largePadding = getResources().getDimensionPixelSize(R.dimen.shr_staggered_product_grid_spacing_large); int smallPadding = getResources().getDimensionPixelSize(R.dimen.shr_staggered_product_grid_spacing_small); recyclerView.addItemDecoration(new ProductGridItemDecoration(largePadding, smallPadding)); // Set cut corner background for API 23+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { view.findViewById(R.id.product_grid) .setBackgroundResource(R.drawable.shr_product_grid_background_shape); } return view; }
Example 7
Source File: MainActivity.java From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // find views by ID for textViews and editTexts mInstanceStateEditText = findViewById(R.id.instanceStateEditText); mSharedPrefEditText = findViewById(R.id.sharedPrefEditText); mRoomEditText = findViewById(R.id.roomEditText); mInstanceStateTextView = findViewById(R.id.instanceStateTextView); mSharedPrefTextView = findViewById(R.id.sharedPrefTextView); // setup viewModel and sharedPreferences mWordViewModel = ViewModelProviders.of(this).get(WordViewModel.class); sharedPreferences = getSharedPreferences(sharedPrefFile, MODE_PRIVATE); // recyclerView setup RecyclerView recyclerView = findViewById(R.id.recyclerView); final WordListAdapter adapter = new WordListAdapter(this); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new LinearLayoutManager(this)); // get all words from view models mWordViewModel.getAllWords().observe(this, new Observer<List<Word>>() { @Override public void onChanged(@Nullable final List<Word> words) { adapter.setWords(words); } }); // set text for value saved using shared preferences mSharedPrefTextView.setText("Text Saved: " + sharedPreferences.getString("sharedPrefString", "")); // set text for value saved using save instance state if (savedInstanceState!= null){ mInstanceStateTextView.setText("Text Saved: " + savedInstanceState.getString("instanceStateKey", "")); } }
Example 8
Source File: TFragment.java From Android-skin-support with MIT License | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_t, null); mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity().getApplication())); mRecyclerView.addItemDecoration(new CustomDividerItemDecoration(getActivity(), LinearLayoutManager.VERTICAL)); mRecyclerView.setAdapter(new TAdapter()); return view; }
Example 9
Source File: AbsWhitelistActivity.java From FCM-for-Mojo with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_blacklist); if (getActionBar() != null) { getActionBar().setDisplayHomeAsUpEnabled(true); } RecyclerView recyclerView = findViewById(android.R.id.list); recyclerView.setLayoutManager(new LinearLayoutManager(this)); mAdapter = createListAdapter(); recyclerView.setAdapter(mAdapter); RecyclerViewHelper.fixOverScroll(recyclerView); mSwitchBar = findViewById(android.R.id.switch_widget); mSwitchBar.setEnabled(false); mSwitchBar.setOnCheckedChangeListener((button, checked) -> { mAdapter.setEnabled(checked); mAdapter.notifyItemRangeChanged(0, mAdapter.getItemCount(), checked); return true; }); fetchWhitelistState(); }
Example 10
Source File: FontChooserDialogFragment.java From Chimee with MIT License | 5 votes |
private void setupRecyclerView(View customView) { RecyclerView recyclerView = customView.findViewById(R.id.rv_font_list); LinearLayoutManager horizontalLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false); recyclerView.setLayoutManager(horizontalLayoutManager); mFonts = getFonts(); adapter = new FontRvAdapter(getContext(), mFonts); adapter.setClickListener(this); recyclerView.setAdapter(adapter); }
Example 11
Source File: CompositeViewRendererFragment.java From RendererRecyclerViewAdapter with Apache License 2.0 | 5 votes |
@Nullable @Override public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_list, container, false); final RendererRecyclerViewAdapter adapter = new RendererRecyclerViewAdapter(); adapter.registerRenderer( new CompositeViewBinder<>( R.layout.item_simple_composite, R.id.recycler_view, DefaultCompositeViewModel.class, Collections.singletonList(new BetweenSpacesItemDecoration(10, 10)) ).registerRenderer(getAnyViewRenderer()) ); // adapter.registerRenderer(...); // adapter.registerRenderer(...); adapter.setItems(mYourDataProvider.getCompositeSimpleItems()); final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); recyclerView.setAdapter(adapter); recyclerView.addItemDecoration(new BetweenSpacesItemDecoration(10, 10)); return view; }
Example 12
Source File: InlineDoubleHeaderFragment.java From header-decor with Apache License 2.0 | 5 votes |
@Override protected void setAdapterAndDecor(@NonNull RecyclerView list) { final InlineDoubleHeaderTestAdapter adapter = new InlineDoubleHeaderTestAdapter(requireContext()); decor = new DoubleHeaderDecoration(adapter, true); setHasOptionsMenu(true); list.setAdapter(adapter); list.addItemDecoration(decor, 1); list.addOnItemTouchListener(this); }
Example 13
Source File: StickyHeaderFragment.java From header-decor with Apache License 2.0 | 5 votes |
@Override protected void setAdapterAndDecor(@NonNull RecyclerView list) { final StickyTestAdapter adapter = new StickyTestAdapter(requireContext()); decor = new StickyHeaderDecoration(adapter); setHasOptionsMenu(true); list.setAdapter(adapter); list.addItemDecoration(decor, 1); list.addOnItemTouchListener(this); }
Example 14
Source File: AccessLogActivity.java From DeviceConnect-Android with MIT License | 5 votes |
@SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_accesslog_date_list, container, false); mListAdapter = new DateListAdapter(inflater); mListAdapter.setOnItemClickListener((v, position) -> gotoAccessLogListFragment(mListAdapter.getItem(position))); mListAdapter.setOnItemRemoveListener((data) -> { AccessLogProvider provider = getAccessLogProvider(); if (provider != null) { provider.remove(data); } }); RecyclerView recyclerView = root.findViewById(R.id.recycler_view_accesslog_date_list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(mListAdapter); recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL)); recyclerView.setOnTouchListener((v, event) -> { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mListAdapter.dismissSnackbar(); break; } return false; }); ItemTouchHelper helper = new ItemTouchHelper(new SwipeToDeleteCallback(getContext()) { @Override public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { mListAdapter.onItemRemove(viewHolder, recyclerView); } }); helper.attachToRecyclerView(recyclerView); setHasOptionsMenu(true); return root; }
Example 15
Source File: DemoFragment.java From EFRConnect-android with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_demo, container, false); RecyclerView recyclerView = view.findViewById(R.id.recylerview_demo_menu); MenuAdapter adapter = new MenuAdapter(list, this, getActivity()); recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2)); recyclerView.setAdapter(adapter); return view; }
Example 16
Source File: FragmentComing.java From Pixiv-Shaft with MIT License | 4 votes |
@Override public void initView(View view) { super.initView(view); RecyclerView recyclerView = view.findViewById(R.id.recy_list); GridLayoutManager layoutManager = new GridLayoutManager(mContext, 6); recyclerView.setLayoutManager(layoutManager); EmojiAdapter adapter = new EmojiAdapter(Emoji.getEmojis(), mContext); adapter.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(View v, int position, int viewType) { final EmojiItem item = adapter.getItemAt(position); String name = item.getName(); String show = baseBind.inputBox.getText().toString(); if (selection < show.length()) { String left = show.substring(0, selection); String right = show.substring(selection); commitString = left + name + right; baseBind.inputBox.setText(left + name + right); baseBind.inputBox.setSelection(selection + name.length()); } else { String result = show + name; commitString = result; baseBind.inputBox.setText(result); baseBind.inputBox.setSelection(result.length()); } Common.showLog(className + selection); } }); recyclerView.setAdapter(adapter); baseBind.inputBox.setOnSelectionChange(new EditTextWithSelection.OnSelectionChange() { @Override public void onChange(int start, int end) { if (start != 0) { selection = start; } } }); }
Example 17
Source File: PictureMultiCuttingActivity.java From PictureSelector with Apache License 2.0 | 4 votes |
/** * 动态添加多图裁剪底部预览图片列表 */ private void addPhotoRecyclerView() { boolean isMultipleSkipCrop = getIntent().getBooleanExtra(UCrop.Options.EXTRA_SKIP_MULTIPLE_CROP, true); mRecyclerView = new RecyclerView(this); mRecyclerView.setId(R.id.id_recycler); mRecyclerView.setBackgroundColor(ContextCompat.getColor(this, R.color.ucrop_color_widget_background)); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, ScreenUtils.dip2px(this, 80)); mRecyclerView.setLayoutParams(lp); LinearLayoutManager mLayoutManager = new LinearLayoutManager(this); mLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); if (isAnimation) { LayoutAnimationController animation = AnimationUtils .loadLayoutAnimation(getApplicationContext(), R.anim.ucrop_layout_animation_fall_down); mRecyclerView.setLayoutAnimation(animation); } mRecyclerView.setLayoutManager(mLayoutManager); // 解决调用 notifyItemChanged 闪烁问题,取消默认动画 ((SimpleItemAnimator) mRecyclerView.getItemAnimator()) .setSupportsChangeAnimations(false); resetCutDataStatus(); list.get(cutIndex).setCut(true); mAdapter = new PicturePhotoGalleryAdapter(this, list); mRecyclerView.setAdapter(mAdapter); if (isMultipleSkipCrop) { mAdapter.setOnItemClickListener(new PicturePhotoGalleryAdapter.OnItemClickListener() { @Override public void onItemClick(int position, View view) { CutInfo cutInfo = list.get(position); if (MimeType.isHasVideo(cutInfo.getMimeType())) { return; } if (cutIndex == position) { return; } resetLastCropStatus(); cutIndex = position; oldCutIndex = cutIndex; resetCutData(); } }); } uCropPhotoBox.addView(mRecyclerView); changeLayoutParams(mShowBottomControls); // 裁剪框居于RecyclerView之上 FrameLayout uCropFrame = findViewById(R.id.ucrop_frame); ((RelativeLayout.LayoutParams) uCropFrame.getLayoutParams()) .addRule(RelativeLayout.ABOVE, R.id.id_recycler); // RecyclerView居于BottomControls之上 ((RelativeLayout.LayoutParams) mRecyclerView.getLayoutParams()) .addRule(RelativeLayout.ABOVE, R.id.controls_wrapper); }
Example 18
Source File: GithubFragment.java From RendererRecyclerViewAdapter with Apache License 2.0 | 4 votes |
@Nullable @Override public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) { View inflate = inflater.inflate(R.layout.fragment_github, container, false); mGithubPresenter = new GithubPresenter( getUIRouter(), getMenuController(), MainManager.getInstance().getStargazersManager(), MainManager.getInstance().getForksManager(), mMainPresenterView ); mSwipeToRefresh = (SwipeRefreshLayout) inflate.findViewById(R.id.refresh); mSwipeToRefresh.setOnRefreshListener(() -> mGithubPresenter.onRefresh()); mRecyclerViewAdapter = new RendererRecyclerViewAdapter(); mRecyclerViewAdapter.setDiffCallback(new ItemsDiffCallback()); mRecyclerViewAdapter.registerRenderer(new LoadMoreViewBinder(R.layout.item_load_more)); mRecyclerViewAdapter.registerRenderer(createStargazerRenderer(R.layout.item_user_full_width)); mRecyclerViewAdapter.registerRenderer(createListRenderer() .registerRenderer(createForkRenderer()) .registerRenderer(createStargazerRenderer(R.layout.item_user_150)) ); mRecyclerViewAdapter.registerRenderer(new ViewBinder<>( R.layout.item_category, CategoryModel.class, (model, finder, payloads) -> finder .find(R.id.title, (ViewProvider<TextView>) view -> view.setText(model.getName())) .setOnClickListener(R.id.viewAll, (v -> mGithubPresenter.onCategoryClicked(model))) )); mLayoutManager = new GridLayoutManager(getContext(), MAX_SPAN_COUNT); mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(final int position) { final Type type = mRecyclerViewAdapter.getType(position); if (type.equals(ForkModel.class) || type.equals(StargazerModel.class)) { return 1; } return 3; } }); mRecyclerView = (RecyclerView) inflate.findViewById(R.id.recycler_view); mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.setAdapter(mRecyclerViewAdapter); mRecyclerView.addItemDecoration(new MyItemDecoration()); mRecyclerView.addOnScrollListener(new EndlessScrollListener() { @Override public void onLoadMore(final int page, final int totalItemsCount) { mGithubPresenter.onLoadMore(); } }); return inflate; }
Example 19
Source File: BackupFragment.java From SAI with GNU General Public License v3.0 | 4 votes |
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mViewModel = new ViewModelProvider(this).get(BackupViewModel.class); RecyclerView recyclerView = findViewById(R.id.rv_packages); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); int padding = requireContext().getResources().getDimensionPixelSize(R.dimen.backup_recycler_top_bottom_padding); recyclerView.addItemDecoration(new RecyclerPaddingDecoration(0, padding, 0, padding)); recyclerView.getRecycledViewPool().setMaxRecycledViews(0, 24); mAdapter = new BackupPackagesAdapter(mViewModel.getSelection(), getViewLifecycleOwner(), getContext()); mAdapter.setInteractionListener(this); recyclerView.setAdapter(mAdapter); setupToolbar(); findViewById(R.id.button_backup_action).setOnClickListener(v -> { Selection<String> selection = mViewModel.getSelection(); if (!selection.hasSelection()) { FilterDialog.newInstance(getString(R.string.backup_filter), mViewModel.getRawFilterConfig(), DefaultFilterConfigViewHolderFactory.class).show(getChildFragmentManager(), null); } else { BatchBackupDialogFragment.newInstance(new ArrayList<>(mViewModel.getSelection().getSelectedKeys())).show(getChildFragmentManager(), null); } }); invalidateAppFeaturesVisibility(); mViewModel.getPackages().observe(getViewLifecycleOwner(), mAdapter::setData); ViewGroup indexingOverlay = findViewById(R.id.overlay_backup_indexing); ProgressBar indexingProgressBar = findViewById(R.id.progress_backup_indexing); TextView indexingStatusText = findViewById(R.id.tv_backup_indexing_status); mViewModel.getIndexingStatus().observe(getViewLifecycleOwner(), status -> { if (status.isInProgress()) { indexingOverlay.setVisibility(View.VISIBLE); indexingStatusText.setText(getString(R.string.backup_indexing, status.progress(), status.goal())); indexingProgressBar.setMax(status.goal()); indexingProgressBar.setProgress(status.progress()); } else { indexingOverlay.setVisibility(View.GONE); } }); mStorageConfigFragment = getChildFragmentManager().findFragmentByTag(FRAGMENT_TAG_DEFAULT_STORAGE_SETUP); FragmentContainerView storageConfigOverlay = findViewById(R.id.fragment_container_backup_storage_setup); mViewModel.getDefaultStorageProvider().getIsSetupLiveData().observe(getViewLifecycleOwner(), isConfigured -> { if (isConfigured) { storageConfigOverlay.setVisibility(View.GONE); if (mStorageConfigFragment != null) { getChildFragmentManager().beginTransaction() .remove(mStorageConfigFragment) .commitNow(); mStorageConfigFragment = null; } OneTimeWarningDialogFragment.showIfNeeded(requireContext(), getChildFragmentManager(), R.string.help, R.string.backup_warning, "backup_faq"); } else { storageConfigOverlay.setVisibility(View.VISIBLE); if (mStorageConfigFragment == null) { mStorageConfigFragment = mViewModel.getDefaultStorageProvider().createSetupFragment(); getChildFragmentManager().beginTransaction() .add(R.id.fragment_container_backup_storage_setup, mStorageConfigFragment, FRAGMENT_TAG_DEFAULT_STORAGE_SETUP) .commitNow(); } } }); PreferencesHelper.getInstance(requireContext()).getPrefs().registerOnSharedPreferenceChangeListener(this); }
Example 20
Source File: MainActivity.java From RecyclerViewDecoration with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mStyleStrs = getResources().getStringArray(R.array.style_list); mRvData = (RecyclerView) findViewById(R.id.rv_data); //set layout manager RecyclerViewStyleHelper.toLinearLayout(mRvData, LinearLayout.VERTICAL); //add itemdecoration mRvData.addItemDecoration( new RecyclerViewLinearItemDecoration.Builder(this).color(Color.GRAY).thickness(1).create()); mRvData.setAdapter(new RecyclerViewAdapter<>(this, Arrays.asList(mStyleStrs) , R.layout.item_main_list, new RecyclerViewSingleTypeProcessor<String>() { @Override public void onBindViewHolder(RecyclerViewViewHolder holder, final int position, String data) { TextView tvTitle = holder.getView(R.id.tv_title); tvTitle.setText(data); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switch (position) { case 0: jumpTo(CommonStyleActivity.class); break; case 1: jumpTo(SpacingStyleActivity.class); break; case 2: jumpTo(IgnoreStyleActivity.class); break; case 3: jumpTo(StickyHeadActivity.class); break; default: break; } } }); } })); }