I am creating a StaggeredGridView using https://github.com/etsy/AndroidStaggeredGrid . But when I try to initialze the StaggeredGridView like follows:-
public class HomeFragment extends ListFragment
{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View vi = inflater.inflate(R.layout.fragment_home, container, false);
mGridView =(StaggeredGridView)vi.findViewById(R.id.grid_view); // Issue here
return vi;
}
}
This is my Xml file:-
<com.etsy.android.grid.StaggeredGridView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/grid_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:item_margin="8dp"
app:column_count="3" />
I get the following error:-
06-09 09:07:16.568: E/AndroidRuntime(1836): Caused by: java.lang.RuntimeException: Content has view with id attribute 'android.R.id.list' that is not a ListView class
If I change the ListFragment
to Fragment
I get a NullPointerException while I try to set an adapter
What could be the cause?