现在已经有这个问题..我正在尝试连接到一个回复图像位置的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
}
答案 0 :(得分:0)
是否在模拟器上? 如果是这样的话,试着把它添加到dns ..
Window>Preferences>Android>Launch
Default emulator options: -dns-server 8.8.8.8,8.8.4.4