![](/img/trans.png)
[英]I want to retrieve the image from parse! Storing the image in parse works! How can i get the image from parse in imageview?
[英]i want to get image from imageview?
我有这个xml,我想从thisi mageview获取图像。
<ImageView
android:id="@+id/result_resultView"
android:layout_width="200dip"
android:layout_height="200dip"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="@drawable/pic_boarder"
android:maxHeight="100dip" />
在活动中
ImageView view = (ImageView) findViewById(R.id.result_resultView);
查看.setImageResource(R.drawable.m_2);
我想通过具有id result_resultView的imageview获得m_2。
使用getDrawable()
方法返回Drawable 。 此Drawable是BitmapDrawable的实例,可让您获取Bitmap。
Bitmap image = null;
if(imageView.getDrawable() instanceof BitMapDrawable){
BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
image = drawable.getBitmap();
}
编辑我建议在投射之前更好地检查它是否重新布局了BitmapDrawable的实例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.