这个问题已经有一段时间了。我正在尝试连接到一个回显图像位置的 php 脚本,并且我试图最终在我的应用程序上显示图片。但是,我什至不确定我是否正在连接到 php 脚本。
“http 连接错误,unknownhost 错误……”
谢谢。
尝试 {
// Execute HTTP Post Request
ResponseHandler<String> responseHandler=new BasicResponseHandler();
String responseBody = httpclient.execute(httppost, responseHandler);
Log.d("test", responseBody);
// Toast.makeText(getApplicationContext(), responseBody, Toast.LENGTH_LONG).show();
// Loader image - will be shown before loading image
int loader = R.drawable.icon;
// Imageview to show
ImageView image = (ImageView) findViewById(R.id.image);
// Image url
String image_url = "http://www.xxx.php";
String fullUrl = "http://www.xxx.php"+responseBody;
test.setText(fullUrl);
// ImageLoader class instance
ImageLoader imgLoader = new ImageLoader(getApplicationContext());
// whenever you want to load an image from url
// call DisplayImage function
// url - image url to load
// loader - loader image, will be displayed before getting image
// image - ImageView
imgLoader.DisplayImage(fullUrl, loader, image);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}