【发布时间】:2017-05-11 12:50:30
【问题描述】:
这是我的对象
public Object instantiateItem(ViewGroup container, int position) {
layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = layoutInflater.inflate(R.layout.image_fullscreen_preview, container, false);
ImageView imageViewPreview = (ImageView) view.findViewById(R.id.image_preview);
Image image = images.get(position);
Glide.with(getActivity()).load(image.getLarge())
.thumbnail(0.5f)
.crossFade()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imageViewPreview);
container.addView(view);
return view;
}
这是我的 onShare 函数。
公共无效 onShareItem() { // 从视图中获取位图图像
ImageView i = (ImageView) getActivity().getLayoutInflater().inflate(R.layout.image_fullscreen_preview,null).findViewById(R.id.image_preview);
//imageViewPreview = (ImageView) viewPager.findViewById(R.id.image_preview);
// Get access to the URI for the bitmap
Uri bmpUri = getLocalBitmapUri(imageViewPreview);
if (bmpUri != null) {
// Construct a ShareIntent with link to image
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
shareIntent.setType("image/*");
// Launch sharing dialog for image
startActivity(Intent.createChooser(shareIntent, "Share Image"));
} else {
// ...sharing failed, handle error
}
}
当我调试应用程序时,imageview 为空..
我想在 R.id.image_preview 中分享图片 那么我怎样才能访问 R.id.image_preview 图像。
【问题讨论】:
标签: android android-imageview layout-inflater