2015-12-12 83 views

回答

0

對於[從相機]設置拍攝的圖像圖像視圖:

Intent getImageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
      startActivityForResult(getImageIntent, 1); 

    @Override 
    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     if (requestCode == 1) { 
      if (resultCode == Activity.RESULT_OK) { 
       imageCounter++; 
       takePicture(data); 
      } else if (resultCode == Activity.RESULT_CANCELED) { 

      } 
     } 
    } 

    protected void takePicture(Intent data) { 
     Bundle b = data.getExtras(); 
     Bitmap pic = (Bitmap) b.get("data"); 
     if (pic != null) { 
      ImageView img = new ImageView(this); 
      ((LinearLayout) findViewById(R.id.captured_image_layout)) 
      .addView(img); 
      img.setLayoutParams(new LinearLayout.LayoutParams(0, 
       LinearLayout.LayoutParams.WRAP_CONTENT, 0.33f)); 
      img.setPadding(5, 5, 5, 5); 
      img.setImageBitmap(pic); 
     } 
    } 
+0

謝謝shubham :)我真的很感激它!它的工作原理:D非常感謝你:) –

相關問題