Tengo un problema al implementar Glide en mi GridView, me base en esta pagina Glide
activity_index.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
android:id="@+id/main.appbar"
android:layout_width="match_parent"
android:layout_height="300dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true" >
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/main.collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
app:title="Bienvenido">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="30dp"
android:lineSpacingExtra="8dp"
android:id="@+id/data_checkin" />
<RelativeLayout
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:src="@drawable/picture"
android:tint="@color/colorPrimary"
app:backgroundTint="#fff"
app:borderWidth="0dp"
app:fabSize="mini"
app:layout_anchorGravity="bottom|end"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@+id/fab_home"
android:layout_marginEnd="20dp" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginLeft="16dp"
android:src="@drawable/home"
android:tint="@color/colorPrimary"
app:backgroundTint="#fff"
app:borderWidth="0dp"
app:fabSize="mini"
app:layout_anchorGravity="bottom|end"
android:layout_marginRight="16dp"
android:layout_marginEnd="23dp"
android:layout_marginBottom="29dp"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/main.toolbar"
android:layout_width="match_parent"
android:layout_height="56dp"
app:popupTheme="@style/ThemeScot"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_horizontal_margin">
<GridView
android:id="@+id/grid_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:columnWidth="300dp"
android:drawSelectorOnTop="true"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp"
android:focusable="true"
android:clickable="true" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
IndexActivity.java
ArrayList<String> strings = new ArrayList<String>();
if (checkIn.getImages().size() > 0) {//valido de que existan imagenes
for (ImageData object: checkIn.getImages()) {
strings.add(object.getPath());//al ArrayList le agrego los Bitmaps
}//for
gridView.setAdapter(new ImageAdapter(this, strings));//seteo las imagenes al gridView
}//./if
ImageAdapter.java
public class ImageAdapter extends ArrayAdapter {
private Context mContext;
private ArrayList<String> imagesList;
private LayoutInflater inflater;
public ImageAdapter(Context context, ArrayList<String> imagesList){
super(context, R.layout.activity_index, imagesList);//recibe como parametros el Contexto y un ArrayList de Bitmaps
this.mContext = context;//se asgina valores
this.imagesList = imagesList;//se asgina valores
inflater = LayoutInflater.from(mContext);
}//./constructor
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (null == convertView) {
convertView = inflater.inflate(R.layout.activity_index, parent, false);
}
Glide.with(mContext).load(imagesList.get(position)).into((ImageView) convertView);
return convertView;
}
}//./clase
me esta marcando el siguiente error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.tritonix.scotproyect, PID: 4923
java.lang.ClassCastException: android.support.design.widget.CoordinatorLayout cannot be cast to android.widget.ImageView
at com.example.tritonix.scotproyect.ImageAdapter.getView(ImageAdapter.java:65)
at android.widget.AbsListView.obtainView(AbsListView.java:2828)
at android.widget.GridView.onMeasure(GridView.java:1064)
at android.view.View.measure(View.java:18648)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:721)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:612)
at android.view.View.measure(View.java:18648)
at android.support.v4.widget.NestedScrollView.measureChildWithMargins(NestedScrollView.java:1420)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.support.v4.widget.NestedScrollView.onMeasure(NestedScrollView.java:482)
at android.view.View.measure(View.java:18648)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:703)
at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:90)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1367)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:768)
at android.view.View.measure(View.java:18648)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.view.View.measure(View.java:18648)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:721)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:612)
at android.view.View.measure(View.java:18648)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:3012)
at android.view.View.measure(View.java:18648)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2298)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1345)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1644)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1230)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6748)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
at android.view.Choreographer.doCallbacks(Choreographer.java:590)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6134)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)