前端点击图片将跳出显示框显示图片

1 篇文章 0 订阅
该写法是在easy UI框架下所用!
主要的功能就是点击详情时候跳出一个显示框将服务器中的PDF文件显示出来.
后台数据库中存储的是已经上传了的文件路径!如果去掉<th>中的formatter:detail前端将
显示只是文件路径,例如:http://127.0.0.1:8080/PFSSmes/uploadFile/changeInfoPDF/bad_0001_20161001083020_20161013100118.pdf


详细的操作代码如下.

1-调用JS方法时候的写法!!!!!!
<th data-options="field:'detailFilePath',width:165,align:'center',formatter:detail">详情</th>

2-点击详情时候跳出的显示框!
<div id="detailDlg" closed="true" class="easyui-dialog"
data-options="iconCls:'icon-save',title: 'pdf详情',"
style="width: 800px; height: 600px; padding: 10px">
<div id='pdfFile' style="width: 100%; height: 100%;"></div>
</div>


3-JS方法详细代码
<script type="text/javascript">
function detail(detailFilePath) {
return "<a href='javascript:;'><img width='8px' src='../../static/images/icons_menu/detail.png' οnclick='clickSettings(\""
+ detailFilePath + "\")'/></a>";
}
function clickSettings(detailFilePath) {
PDFObject.embed(detailFilePath, "#pdfFile");
$('#detailDlg').dialog('open');
}

</script>


效果如下:1-主页显示的情况,


2-当点击单行的详情时,将跳出显示框。


要在 Android 中实现点击图片跳出弹窗的效果,可以使用 PopupWindow 控件,具体步骤如下: 1. 在布局文件中添加一个 ImageView 控件,并为其设置点击事件。 2. 在点击事件中创建一个 PopupWindow 对象,并设置其布局和显示位置。 3. 在 PopupWindow 中添加想要显示的内容。 下面是一个简单的实现示例: XML布局文件: ``` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/imageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image" /> </RelativeLayout> ``` Java代码: ``` ImageView imageView = findViewById(R.id.imageView); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // 创建 PopupWindow 对象 PopupWindow popupWindow = new PopupWindow(MainActivity.this); // 设置布局 View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.popup_layout, null); popupWindow.setContentView(view); // 设置宽高 popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); // 设置显示位置 int[] location = new int[2]; v.getLocationOnScreen(location); popupWindow.showAtLocation(findViewById(R.id.container), Gravity.NO_GRAVITY, location[0], location[1] + v.getHeight()); // 添加内容 TextView textView = view.findViewById(R.id.textView); textView.setText("这是弹窗中的内容。"); } }); ``` 在上述代码中,我们首先为 ImageView 控件设置了点击事件,当用户点击图片时,会创建一个 PopupWindow 对象并显示图片的下方。在 PopupWindow 中我们添加了一个简单的 TextView 控件来展示弹窗中的内容。 你可以根据实际需求修改布局和代码来实现更复杂的效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值