LinearLayoutManager cannot resolve getOrientation ()

I have a RecyclerView implemented in a snippet, and I'm trying to add delimiters to the code. I have a RecylcerView working as intended, but LinearLayoutManager cannot enable the getOrientation() function.

 private RecyclerView mRecyclerView; private RecyclerView.Adapter mAdapter; private RecyclerView.LayoutManager mLayoutManager; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = (View) inflater.inflate(R.layout.fragment_settings, null); getActivity().setTitle("Settings"); mRecyclerView = (RecyclerView) root.findViewById(R.id.recycler_view_settings); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getContext()); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new SettingsAdapter(getResources().getStringArray(R.array.setting_list)); mRecyclerView.setAdapter(mAdapter); DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), mLayoutManager.getOrientation()); mRecyclerView.addItemDecoration(dividerItemDecoration); return root; } 
+8
android android-recyclerview linearlayoutmanager
source share
2 answers

Edit

 private RecyclerView.LayoutManager mLayoutManager; 

to

 private LinearLayoutManager mLayoutManager; 
+9
source share

I have the same problem when I create a separator. You can simply set the orientation yourself, LinearLayoutManager.VERTICAL or LinearLayoutManager.HORIZONTAL , according to the orientation of your RecyclerView . This works for me.

+3
source share

All Articles