@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mRecyclerView = new RecyclerView(container.getContext()); mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mRecyclerView.setLayoutManager(new GridLayoutManager(container.getContext(), 4)); mRecyclerView.setAdapter(new Adapter()); return mRecyclerView; }
/** * Create the RecyclerView and set it as the dialog view. * * @return the created RecyclerView */ private RecyclerView createRecyclerView() { RecyclerView recyclerView = new RecyclerView(getContext()); RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); recyclerView.setLayoutParams(params); setContentView(recyclerView); return recyclerView; }
/** * Create the RecyclerView and set it as the dialog view. * * @return the created RecyclerView */ private RecyclerView createRecyclerView() { RecyclerView recyclerView = new RecyclerView(getContext()); RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); recyclerView.setLayoutParams(params); setView(recyclerView); return recyclerView; }
mRecyclerView = new RecyclerView(ctx); mContainer.addView(mRecyclerView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
/** * Override this method to provide a custom RecyclerView. * The default one is using the theme's recyclerViewStyle. */ @NonNull protected RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup container, @Nullable Bundle savedInstanceState) { return new RecyclerView(inflater.getContext(), null, R.attr.recyclerViewStyle); }
private void layout(Context context, AttributeSet attrs) { fastScroller = new FastScroller(context, attrs); fastScroller.setId(R.id.fast_scroller); recyclerView = new RecyclerView(context, attrs); recyclerView.setId(R.id.recycler_view); } }
public MenuBottomSheetDialog(@NonNull Context context) { super(context); RecyclerView content = new RecyclerView(context); content.setLayoutManager(new LinearLayoutManager(context)); content.setAdapter(new ItemAdapter()); int verticalPadding = content.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_menu_vertical_margin); content.setPadding(0, verticalPadding, 0, verticalPadding); setContentView(content); content.setBackgroundColor(StyledAttributesHelper.getColor(context, R.attr.colorBackgroundFloating, 0)); }
RecyclerView recyclerView = new RecyclerView(this); setContentView(recyclerView); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
private void init() { mCommandAdapter = new CommandListSuggestionsAdapter(getContext()); mCommandAdapter.setClickListener(this); List<CommandAliasManager.CommandAlias> additionalItems = new ArrayList<>(); additionalItems.add(CommandAliasManager.CommandAlias.raw("wait", "<seconds>", "")); additionalItems.add(CommandAliasManager.CommandAlias.raw("wait-for", "<channel>", "")); mCommandAdapter.setAdditionalItems(additionalItems); mSuggestionsList = new RecyclerView(getContext()); mSuggestionsList.setAdapter(mCommandAdapter); mSuggestionsList.setLayoutManager(new LinearLayoutManager(getContext())); mPopupAnchor = new View(getContext()); mPopupWindow = new PopupWindow(getContext(), null, android.R.attr.listPopupWindowStyle); mPopupWindow.setContentView(mSuggestionsList); mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); mPopupItemHeight = StyledAttributesHelper.getDimensionPixelSize(getContext(), android.R.attr.listPreferredItemHeightSmall, 0); mMaxPopupHeight = getResources().getDimensionPixelSize(R.dimen.list_popup_max_height); addTextChangedListener(new SimpleTextWatcher((Editable s) -> { if (enoughToFilter()) performFiltering(false); else dismissDropDown(); })); }