2016-04-18 9 views
0

私は意図を使ってカメラを開き、その結果の画像をビットマップとして保存しようとしています。次に、Googleマップでマーカーをクリックすると、このビットマップをメインのレイアウトにポップアップウィンドウを挿入するために使用する別のレイアウトに渡したいと考えています。ImageViewをlayoutinflatorコンテナのビットマップとして設定する

しかし、私はエラーを取得しています: 「のjava.lang.NullPointerException:nullのオブジェクト参照に 『無効android.widget.ImageView.setImageBitmap(android.graphics.Bitmap)』を仮想メソッドを呼び出すための試み」

MainActivity:

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 

    // if the action was to capture a picture, then store all relevant data in the database 
    if (requestCode == 1) { 
     if (resultCode == RESULT_OK) { 
      Toast.makeText(this, "Picture Received"/*data.getData().toString()*/, Toast.LENGTH_SHORT).show(); 

      Bundle extras = data.getExtras(); 
      imageBitmap = (Bitmap) extras.get("data"); 
      //imageView.setImageBitmap(imageBitmap); 
     } 
    } 
} 


@Override 
public boolean onMarkerClick(Marker marker) { 

    layoutInflator = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE); 
    ViewGroup container = (ViewGroup) layoutInflator.inflate(R.layout.imagecontainer, null); 

    ImageView image = (ImageView) findViewById(R.id.imageView); 
    image.setImageBitmap(imageBitmap); 

    popUpWindow = new PopupWindow(container, 800, 1220, true); 
    popUpWindow.setBackgroundDrawable(new BitmapDrawable()); 
    popUpWindow.setOutsideTouchable(true); 
    popUpWindow.showAtLocation(relativeLayout, Gravity.CENTER, Gravity.CENTER_HORIZONTAL, Gravity.CENTER_VERTICAL); 

    return false; 
} 

imagecontainer.xml:

は、ここに私のコードの一部であります

答えて

0

あなたは(逃したコンテナを?)もしかして:

ImageView image = (ImageView) container.findViewById(R.id.imageView); 
+0

ありがとうございました! 「コンテナ」を前に置くのを忘れてしまった。 – rgins16

関連する問題