我进行了搜索,但在互联网上找不到有用的答案。这就是我提出这个问题的原因。我喜欢在getView
自定义 ArrayAdapter 类的方法中加载相机和捕获图像。相机已加载并捕获图像,但从onActivityResult()
未被调用。我的代码如下所示。
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
ViewHolder viewHolder=new ViewHolder();
LayoutInflater inflater = (LayoutInflater) this.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(vi==null){
vi = inflater.inflate(R.layout.list_row, parent, false);
viewHolder.id=(TextView)vi.findViewById(R.id.title);
viewHolder.thumbnailImage=(ImageView)vi.findViewById(R.id.list_image);
viewHolder.arrow=(ImageView)vi.findViewById(R.id.list_arrow);
vi.setTag(viewHolder);
}
else
viewHolder=(ViewHolder) vi.getTag();
// Setting all values in listview
viewHolder.id.setText(listIDs.get(position));
viewHolder.thumbnailImage.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
((Activity)context).startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
return vi;
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
// Bitmap photo = (Bitmap) data.getExtras().get("data");
// imageView.setImageBitmap(photo);
}
}
然后自定义适配器类从类中激活ListFragment
为
customList_Adaptor adapter = new customList_Adaptor(
getActivity(), R.layout.list_row, listIDs);
如何修改以便调用 onActivityResult() 方法。谢谢