フラグメントにRecyclerView
実装されており、コードに仕切りを追加しようとしています。RecylcerView
意図したとおりに動作していLinearLayoutManager
ますが、機能を解決できませんgetOrientation()
。
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;
}