0
public void onClick(View v) {
    // TODO Auto-generated method stub

    switch (v.getId()) {

    case R.id.image1:
        i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(i, cameraData);

        break;
    case R.id.image2:
        ii = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(ii, cameraData);
    }
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        bmp = (Bitmap) extras.get("data");
        view1.setImageBitmap(bmp);
        view2.setImageBitmap(bmp);
    }
}

カメラで2つの画像を撮り、これらの画像を2つの別々の画像に表示したいと思いますImageViews。写真を撮りましたが、両方に同じ画像が表示されImageViewsます。本当に行き詰まっています。

4

3 に答える 3

2

次のようなことを試すことができます:

public void onClick(View v) { // TODO Auto-generated method stub

    switch (v.getId()) {

    case R.id.image1:
        i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(i, 1);

        break;
    case R.id.image2:
        ii = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(ii, 2);
  }
}

その後、

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    switch(requestCode){
    case 1:
       if(resultCode == RESULT_OK){
          Bundle extras = data.getExtras();
          bmp = (Bitmap) extras.get("data");
          view1.setImageBitmap(bmp);
       }
       break;
    case 2:
       if(resultCode == RESULT_OK) {
            Bundle extras = data.getExtras();
            bmp = (Bitmap) extras.get("data");
            view2.setImageBitmap(bmp);
        }
       break;
     }
}
于 2013-03-18T09:02:48.383 に答える
1

これを試して:

public void onClick(View v) {
        // TODO Auto-generated method stub

        switch (v.getId()) {
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        case R.id.image1:

            startActivityForResult(i, 101);

            break;
        case R.id.image2:

            startActivityForResult(i, 102);
      }
}


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);

        if (if (requestCode == 101 && resultCode == RESULT_OK)) {
            Bundle extras = data.getExtras();
            bmp = (Bitmap) extras.get("data");
            view1.setImageBitmap(bmp);

}
        if (if (requestCode ==102 && resultCode == RESULT_OK)) {
            Bundle extras = data.getExtras();
            bmp = (Bitmap) extras.get("data");

            view2.setImageBitmap(bmp);
}
于 2013-03-18T09:03:56.603 に答える