1
在我的应用程序中,我正在将图像上载到服务器上。在下面的代码中,我从可绘制文件夹上传图像。 但是我怎样才能从布局xml中的图像视图上传图像? 同样喜欢findviewbyid.imgid从android应用程序上传图片
我的布局名称是main.xml中和图像ID imgid
好心帮我...
Bitmap bitmap =
BitmapFactory.decodeResource(getResources(),R.drawable.avatar);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); //compress to which format you want.
byte [] byte_arr = stream.toByteArray();
String image_str = Base64.encodeBytes(byte_arr);
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("image",image_str));
感谢名单krutik。但我想知道如何在图像视图中获取图像...? – CVD 2012-03-29 09:45:32