![](/img/trans.png)
[英]android.support.v7.widget.AppCompatImageView cannot be cast to android.view.ViewGroup
[英]android.support.v7.widget.AppCompatImageView cannot be cast to com.rey.material.widget.ImageView
我想将URL加载到与当前活动布局不同的布局中的imageView中。
我不知道这个com.rey.material包是什么以及它的来源。 我想也许它已经被我导入的模板使用了。 您对如何解决此问题有想法吗?
theListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, final View view, final int pos, long l) {
// Unfold cell first then Change Stuff inside
// toggle clicked cell state
((FoldingCell) view).toggle(false);
// register in adapter that state for selected cell is toggled
adapter.registerToggle(pos);
final LayoutInflater factory = getLayoutInflater();
final View cell = factory.inflate(R.layout.cell, null);
ImageView image = (ImageView) cell.findViewById(R.id.head_image);
Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(image);
}
});
这是将所有内容包装在一起的布局:
<com.ramotion.foldingcell.FoldingCell xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:folding-cell="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
folding-cell:additionalFlipsCount="2"
folding-cell:animationDuration="1300"
folding-cell:backSideColor="@color/bgBackSideColor"
folding-cell:cameraHeight="30">
<!-- CONTENT (UNFOLDED) LAYOUT (MUST BE AT LEAST 2x times BIGGER than content layout bellow)-->
<include layout="@layout/cell_content_layout" />
<!-- TITLE (FOLDED) LAYOUT (MUST BE AT LEAST 2x times SMALLER than content layout above) -->
<include layout="@layout/cell_title_layout" />
</com.ramotion.foldingcell.FoldingCell>
这是包含特定imageView的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/head_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/head_image" />
</RelativeLayout>
</LinearLayout>
没关系,这是我的错误点击:
为ImageView
导入软件包时,我单击了第一个软件包而不是通常的软件包,这导致了此问题。 解:
更换
import com.rey.material.widget.ImageView
同
import android.widget.ImageView
我知道我参加晚会很晚,但是以防万一有人为同样的问题而烦恼,这是当我尝试在寻呼机适配器图像中添加缩放功能时可能对我有用的一种解决方案
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/head_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/head_image" />
</RelativeLayout>
在上面的代码中,只需将<ImageView
替换为<com.yourPackage.TouchImageView
。
TouchImageView (或其他任何类)是一个自定义类(您需要制作),应扩展android.support.v7.widget.AppCompatImageView
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.