public void onClick(View v) {
Intent intent = null;
switch (v.getId()) {
case R.id.backBtn:
BizEditSettingActivity.this.finish();
break;
case R.id.saveBtn:
getInfo = new GetBusinessInfo();
getInfo.execute();
break;
case R.id.biz_image:
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
myView = inflater.inflate(R.layout.popupwindow, null);
popupWindow = new PopupWindow(myView, LayoutParams.FILL_PARENT, 300, false);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
// 设置PopupWindow的弹出和消失效果
popupWindow.setAnimationStyle(R.style.popupAnimation);
albumsBtn = (Button) myView.findViewById(R.id.albumsBtn);
albumsBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent picture = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(picture, ConstantUtils.IMAGE_FROM_ALBUMS);
popupWindow.dismiss();
}
});
cancleBtn = (Button) myView.findViewById(R.id.cancleBtn);
cancleBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
popupWindow.dismiss();
}
});
popupWindow.showAtLocation(cameraBtn, Gravity.BOTTOM, 0, 0);
break;
}
}
};
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (resultCode) {
case ConstantUtils.IMAGE_FROM_ALBUMS:
if (resultCode == Activity.RESULT_OK && null != data) {
Uri selectedImage = data.getData();
String[] filePathColumns = { MediaStore.Images.Media.DATA };
Cursor c = this.getContentResolver().query(selectedImage, filePathColumns, null, null, null);
c.moveToFirst();
int columnIndex = c.getColumnIndex(filePathColumns[0]);
imagePath = c.getString(columnIndex);
c.close();
}
break;
default:
break;
}
}
问题的关系代码贴上了,搞了快一下午了,也没找到是哪的问题
12 个解决方案
#1
请问你这是访问相册吗?
#2
switch (resultCode) {话说你这里应该是requestCode吧
#3
不仔细看还真看不出来
#4
是调用相册
if (data == null || data.getExtras() == null) {
return;
} else {
Uri selectedImage = data.getData();
String[] filePathColumns = { MediaStore.Images.Media.DATA };
Cursor c = this.getContentResolver().query(selectedImage, filePathColumns, null, null, null);
c.moveToFirst();
int columnIndex = c.getColumnIndex(filePathColumns[0]);
imagePath = c.getString(columnIndex);
c.close();
}
方法稍微改了一下,还是没有被调用
if (data == null || data.getExtras() == null) {
return;
} else {
Uri selectedImage = data.getData();
String[] filePathColumns = { MediaStore.Images.Media.DATA };
Cursor c = this.getContentResolver().query(selectedImage, filePathColumns, null, null, null);
c.moveToFirst();
int columnIndex = c.getColumnIndex(filePathColumns[0]);
imagePath = c.getString(columnIndex);
c.close();
}
方法稍微改了一下,还是没有被调用
#5
switch (resultCode) {不是这里的问题吗,能进来onActivityResult了吗
#6
onActivityResult进不去
startActivityForResult所在的方法体运行成功,但是回调onActivityResult无效
startActivityForResult所在的方法体运行成功,但是回调onActivityResult无效
#7
switch (resultCode) 改了没
#8
switch (resultCode) 改成switch (requestCode)
#9
switch (resultCode) 改成switch (requestCode)
#10
抄袭
#11
解决了,谢谢各位
调用手机相机,相册等功能时,回调对应的是requestCode
而通常的startActivityForResult,对应的是resultCode
麻烦大家了
调用手机相机,相册等功能时,回调对应的是requestCode
而通常的startActivityForResult,对应的是resultCode
麻烦大家了
#12
其实我昨天在2#就已经解答了,你没采纳
祝你好运!
#1
请问你这是访问相册吗?
#2
switch (resultCode) {话说你这里应该是requestCode吧
#3
不仔细看还真看不出来
#4
是调用相册
if (data == null || data.getExtras() == null) {
return;
} else {
Uri selectedImage = data.getData();
String[] filePathColumns = { MediaStore.Images.Media.DATA };
Cursor c = this.getContentResolver().query(selectedImage, filePathColumns, null, null, null);
c.moveToFirst();
int columnIndex = c.getColumnIndex(filePathColumns[0]);
imagePath = c.getString(columnIndex);
c.close();
}
方法稍微改了一下,还是没有被调用
if (data == null || data.getExtras() == null) {
return;
} else {
Uri selectedImage = data.getData();
String[] filePathColumns = { MediaStore.Images.Media.DATA };
Cursor c = this.getContentResolver().query(selectedImage, filePathColumns, null, null, null);
c.moveToFirst();
int columnIndex = c.getColumnIndex(filePathColumns[0]);
imagePath = c.getString(columnIndex);
c.close();
}
方法稍微改了一下,还是没有被调用
#5
switch (resultCode) {不是这里的问题吗,能进来onActivityResult了吗
#6
onActivityResult进不去
startActivityForResult所在的方法体运行成功,但是回调onActivityResult无效
startActivityForResult所在的方法体运行成功,但是回调onActivityResult无效
#7
switch (resultCode) 改了没
#8
switch (resultCode) 改成switch (requestCode)
#9
switch (resultCode) 改成switch (requestCode)
#10
抄袭
#11
解决了,谢谢各位
调用手机相机,相册等功能时,回调对应的是requestCode
而通常的startActivityForResult,对应的是resultCode
麻烦大家了
调用手机相机,相册等功能时,回调对应的是requestCode
而通常的startActivityForResult,对应的是resultCode
麻烦大家了
#12
其实我昨天在2#就已经解答了,你没采纳
祝你好运!