以前自己都不知道怎么去显示服务器端的图片,还好在apkbus论坛上找到一个特别简单的例子。虽然一天天忙忙碌碌,但是自己内心其实有一种想逃的心里,说不定哪天就会冒出来。

1、首先服务器端图片

这里的ImageServlet.java,没有做相关处理

这里启动tomcat,这时在浏览器中输入http://localhost:8080/ReadImage1/image/a.jpg

这时应该能看到这张图片。

2、android程序

布局文件:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="网路图片地址" /> <EditText
android:id="@+id/editText"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="http://192.168.0.121:8081/ReadImage1/image/" /> <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="显示" /> <WebView
android:id="@+id/webView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" /> </LinearLayout>

相关后台代码

package com.haofs.demo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText; public class ImageClientActivity extends Activity implements OnClickListener {
private Button button;
private EditText editText;
private WebView webView; @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button) findViewById(R.id.button1);
editText = (EditText) findViewById(R.id.editText);
webView = (WebView) findViewById(R.id.webView); button.setOnClickListener(this);
} @Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
webView.loadUrl(editText.getText().toString());
}
}

本文来自:

从Android客户端加载服务端的图片
http://www.apkbus.com/forum.php?mod=viewthread&tid=97293
(出处: Android开发论坛 - 安卓开发论坛 - Android开发 - 安卓论坛 - 移动互联网门户)

生活的一步一步,思想的一寸一寸,无时无刻......

app开发历程——android手机显示服务器端图片思路的更多相关文章

  1. app开发历程————Android程序解析服务器端的JSON格式数据,显示在界面上

    上一篇文章写的是服务器端利用Servlet 返回JSON字符串,本文主要是利用android客户端访问服务器端链接,解析JSON格式数据,放到相应的位置上. 首先,android程序的布局文件main ...

  2. Android ImageView显示本地图片

    Android ImageView 显示本地图片 布局文件 <?xml version="1.0" encoding="utf-8"?> <R ...

  3. HBuilder mui 手机app开发 Android手机app开发 ios手机app开发 打开新页面 预加载页面 关闭页面

    创建子页面 在mobile app开发过程中,经常遇到卡头卡尾的页面,此时若使用局部滚动,在android手机上会出现滚动不流畅的问题: mui的解决思路是:将需要滚动的区域通过单独的webview实 ...

  4. 将批量下载的博客导入到手机后,通过豆约翰博客阅读器APP(Android手机)进行浏览,白字黑底,保护眼睛,图文并茂。

    首先下面演示的博文来自于以下地址:http://www.douban.com/note/423939291/ 需要先通过博客备份专家将导出的博文导入到手机(还不会用的朋友请先阅读http://www. ...

  5. Android imageview显示圆形图片

    需要ImageView显示圆形图片做法如下 public static Bitmap toRoundCorner(Bitmap bitmap, float ratio) { System.out.pr ...

  6. Android手机适配——UI图片适配

    转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/50727753 在Android项目当中,drawable文件夹都是用来放置图片资源 ...

  7. Android系统移植与调试之------->如何修改Android手机显示的4G信号强度的格子数

    在修改显示的信号强度之前,先了解一下什么是dB,什么是dBm? 1.dB dB是一个表征相对值的值,纯粹的比值,只表示两个量的相对大小关系,没有单位,当考虑甲的功率相比于乙功率大或小多少个dB时, 按 ...

  8. android -------- GifView 显示gif图片

    最近的项目需要在界面显示Gif动图,查找网络资料,总结了一下,分享一下, 一个GifView的gif图加载库以有效地显示GIF, 您可以启动,暂停和停止gifView 在app 的 build.gra ...

  9. HBuilder mui 手机app开发 Android手机app开发 ios手机app开发

    经过一段时间的学习,做公司项目,对mui框架有了更加深入完整的了解,其实刚开始接触HBuilder中的mui框架只是简单的了解,并没有深入的研究,后来由于工作的需求,不得不深入研究,并运用的项目中去. ...

随机推荐

  1. 在ssh框架中注解方式需要注意的几个问题

    1.注解方式的时候 Spring 2.5 引入了 @Autowired 注释,它可以对类成员变量.方法及构造函数进行标注,完成自动装配的工作. 通过 @Autowired的使用来消除 set ,get ...

  2. session在登录中的使用

    package action.exam; import java.util.Map; import com.opensymphony.xwork2.ActionContext; import com. ...

  3. Linq101-Aggregate

    using System; using System.Collections.Generic; using System.Linq; namespace Linq101 { class Aggrega ...

  4. 关于调用office com组件导出Excel

    服务器环境: 环境为win2008 r2,系统为64位,程序是C#的winform.因为需要处理数据,然后生成Excel,耗时太长,就使用了多线程.winform程序是由计划任务启动,每天晚上去跑. ...

  5. 图解MonoForAndroid开发环境搭建

    电脑系统:windows 8.1 企业版 预装VS:2010旗舰版+2013 with update2旗舰版 ==================================== 1.1 安装ja ...

  6. 访问的是A网址,但是跳转B网址的内容,地址栏还是A网址

    最近家里宽带续费,是用小区小广告的宽带,打开http://download.csdn.net/ 或其他一些设计下载.购物商城或威客网址进不去 提示 经过网上大量搜索和请教,都说是以下几点引起的 1.网 ...

  7. UITabBarController自定义二之xib

    UITabBarController自定义二之xib 新建一个xib文件 在UITabBarController的子类方法viewDidLoad方法中加载xib 1.-(void)viewDidLoa ...

  8. Swift - 15 - 导入Foundation使用更多字符串功能

    //: Playground - noun: a place where people can play import Foundation var str = "Hello, playgr ...

  9. /root/.bashrc与/etc/profile的异同

    要搞清bashrc与profile的区别,首先要弄明白什么是交互式shell和非交互式shell,什么是loginshell 和non-loginshell. 交互式模式就是shell等待你的输入,并 ...

  10. 05_Smart-image通过SoftReference提高性能

    文章导读: 文件介绍了常见的图片下载开源插件smart-image, 由于移动设备硬件受限,因此Android的相关app都要考虑到性能的关系, 所以很多的第三方插件都使用到了缓存cache技术,本人 ...