先把效果拿出來看一下,點選新聞圖檔可以彈出一個dialog放大
原理如下:
服務端需要處理:
1、定義一個新聞浏覽頁面,如news_list.php?newsid=1
把新聞浏覽的内容讀取出來
需要注意的是内容裡的圖檔,需要給圖檔增加一個事件onclick=\"javascript:contactsaction.setimgsrc('$url')\"
$code = "<img src=\"$turl\" border=\"0\" onclick=\"javascript:contactsaction.setimgsrc('$url')\" style=\"$stylecss\" onload=\"$onload\" $alt>";
用戶端處理
1、bbsinfo_listhtml.xml 新聞内容顯示模版
2、bbsimgshow.xml 新聞圖檔點選放大效果
3、bbsinfolist.java 新聞内容讀取頁面
4、bbsimageshow.java 圖檔放大頁面
處理過程:
新聞内容頁放置webview控件
當内容顯示出來時,點選圖檔觸發服務端的js事件,用戶端抓取服務端傳回的資料,然後打開圖檔放大窗體,進行顯示。再點選一次就關閉窗體。
1、bbsinfo_listhtml.xml代碼
<webview
android:id="@+id/webview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
2、bbsimgshow.xml代碼
<?xml version="1.0" encoding="utf-8"?>
<linearlayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<imageview android:id="@+id/ivbig"
android:layout_width="wrap_content" android:layout_height="wrap_content"></imageview>
</linearlayout>
3、bbsinfolist.java
4、bbsimageshow.java