在从 xml.as 上的 ImageView 获取 id 后我有一个 ImageView 我们设置了打开画廊和相机选项的 clicklistener 您可以设置来自相机的图像以及画廊 ain #2
profileimage = (ImageView) findViewById(R.id.profileimage);
profileimage.setBackgroundResource(R.drawable.no_img);
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (resultCode == RESULT_CANCELED) {
// TODO
return;
}
Log.e("request code", "1:" + requestCode);
switch (requestCode) {
case CAMERA_SELECT:
Log.e("in camera select", "1");
// Get the camera data
cameracalling(intent);
break;
case Gallery_Select:
ongallerycalling(intent,resultCode);
}
}
private void cameracalling(Intent intent){
Bitmap photo = (Bitmap) intent.getExtras().get("data");
profileimage.setImageBitmap(photo);
}
profileimage.buildDrawingCache();
Bitmap bmap = profileimage.getDrawingCache();
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bmap.compress(Bitmap.CompressFormat.JPEG, 90, bao);
byte [] ba = bao.toByteArray();
bitmapString=Base64.encodeBytes(ba);
Drawable draw = LoadImageFromWebOperations("" + objUserInformationSitesList.getProfileImage());
profileimage.setBackgroundDrawable(draw);
我们正在将位图字符串正确发送到服务器上的图像上传,但是当我们下次打开这个屏幕时,我们上传图像的 web 服务调用将提供所有数据(实际上是这个用户配置文件屏幕)。当我们设置服务器图像时,默认图像也设置在背景上
objUserInformationSitesList
此对象包含解析 Web 服务后的所有信息。在个人资料图片后面,默认图片也是我在 #1 上设置的
如果我无法正确解释,请告诉我。