gpt4 book ai didi

java - 尝试在对话框中使 ImageView 全尺寸不起作用

转载 作者:行者123 更新时间:2023-12-01 18:15:25 24 4
gpt4 key购买 nike

我正在使用Fragments,当我点击 fragment 上的ImageView时,我想获得全尺寸图像mImageReport。我的第二个布局是 test.xml(用于对话框)。

我使用 Picasso 从 URL 获取图像

但问题是我的图像没有出现在新对话框(mImageReport)上。我不知道如何将 test.xml 中的 imageView 与我想要在 fragment 中全屏显示的图像链接...

这是我的代码。

Reports.java:

public class Reports extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (container == null) {
return null;
}
View view = inflater.inflate(R.layout.reports, container, false);
ButterKnife.inject(this, view);

final Dialog nagDialog = new Dialog(getActivity(),android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
nagDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
nagDialog.setCancelable(false);
nagDialog.setContentView(R.layout.test);
Button btnClose = (Button)nagDialog.findViewById(R.id.btnIvClose);
ImageView ivPreview = (ImageView)nagDialog.findViewById(R.id.iv_preview_image);

// Loading image from url in ImageView ... HERE IS THE PROBLEM
Picasso.with(mImageReport.getContext()).load(mCurrentReportString.getUrlImages()).into(ivPreview);
mImageReport.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
nagDialog.show();
}
});

btnClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {

nagDialog.dismiss();
}
});


return view;
}

测试.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/iv_preview_image" />


<Button android:layout_width="match_parent"
android:layout_height="match_parent" android:background="@drawable/fileclose"
android:id="@+id/btnIvClose" android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
</RelativeLayout>

最佳答案

从 fragment onCreateView 调用此方法或根据您的要求...

private void showImage() {
final Dialog nagDialog = new Dialog(getActivity(),android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
nagDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
nagDialog.setCancelable(false);
nagDialog.setContentView(R.layout.test);
Button btnClose = (Button)nagDialog.findViewById(R.id.btnIvClose);
ImageView ivPreview = (ImageView)nagDialog.findViewById(R.id.iv_preview_image);

// Loading image from url in ImageView ... HERE IS THE PROBLEM
Picasso.with(getActivity()).load(mCurrentReportString.getUrlImages()).into(ivPreview);

btnClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {

nagDialog.dismiss();
}
});
nagDialog.show();
}

关于java - 尝试在对话框中使 ImageView 全尺寸不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29945369/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com