I followed the recommendations of recyclerview and created one for the application I am creating, but for some reason it does not scroll down. I have compared it to snippets of Google code, as well as other snippets of code on the Internet, and I see no difference. I posted the image and the code I use. I use tabs, so the recyclerview is populated with a fragment.
What the application looks like:
http://imgur.com/H5uOLFR
adapter class:
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> { private List<Group> groups;
Fragment Class:
public class groupsFragment extends Fragment implements GroupLeaver, GroupRetriever { private RecyclerView rv; private List<Group> groups; private ProgressDialog progressDialog; @Override public void onCreate(Bundle savedInstance){ super.onCreate(savedInstance); Log.d("TEST", "Entered onCreate"); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { AppMain.getController().retrieveGroups(groupsFragment.this); Log.d("TEST", "Entered onCreateView"); View rootView = inflater.inflate(R.layout.groups_fragment, container, false); rv = (RecyclerView) rootView.findViewById(R.id.recyclerView); rv.setLayoutManager(new LinearLayoutManager(getActivity())); Log.d("TEST", "Size of LIST: " + Integer.toString(groups.size())); MyAdapter adapter = new MyAdapter(groups); rv.setAdapter(adapter); return rootView; } @Override public void onMyGroupsFound(List<Group> groups) { Log.d("TEST", "Entered onMyGroupsFound"); Logg.info(this.getClass(), "Found %d groups for member %s", groups.size(), User.getCurrentUser().getDisplayName()); this.groups = groups; } @Override public void onGroupLeft(Group oldGroup) { } @Override public void onGroupLeftFailed(Group group, ParseException e) { } }
Xml layout for recyclerview:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" android:divider="@null"/> </FrameLayout>
The xml layout for recyclerview elements:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp" android:orientation="horizontal"> <LinearLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="3" android:orientation="vertical"> <TextView android:id="@+id/groupName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Group Name" /> <TextView android:id="@+id/groupDate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Group Date" /> <TextView android:id="@+id/groupLocation" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Group Location" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:orientation="vertical"> <TextView android:id="@+id/className" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="right" android:text="Class Name" /> </LinearLayout> </LinearLayout> </FrameLayout>
android android-fragments android-recyclerview recyclerview-layout
Mehul goel
source share