我很难从活动返回信息,我对实现的理解是不完整的。Android加载图库onclick,返回图像位图
我想要的是用户能够点击一个按钮来加载android画廊,选择一个图像,该图像(或图像链接也许)被转换为位图/绘制出现在我的活动UI布局。 (我知道为什么,画廊应用程序中没有任何意图 - 为了编辑我没有访问权限,但我不知道这是什么意思,但我不知道溶液)
ImageView galleryClick = (ImageView)findViewById(R.id.addgallery);
profilePic = (ImageView)findViewById(R.id.profilepic);
galleryClick.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent, "Select Picture"),1);
}
});
我希望是在onActivityFinished会在我的手写的活动被调用,但该方法是从来没有所谓的(我把一个断点在其代码
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == 1) {
// currImageURI is the global variable I'm using to hold the content:// URI of the image
//currImageURI = data.getData();
}
}
}
解决方案?
断点不取决于你如何从IDE启动的应用程序始终尊重。在requestCode == 1块中抛出一条日志消息 - 是否显示? –