<pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);"><span style="color:rgb(128,128,0);"></span></pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);"><span style="color:rgb(0,0,128);font-weight:bold;">protected void </span>onCreate(Bundle savedInstanceState) {<br><span style="color:rgb(0,0,128);font-weight:bold;">super</span>.onCreate(savedInstanceState);<br> setContentView(R.layout.<span style="color:rgb(102,14,122);font-style:italic;font-weight:bold;">activity_main</span>);<br><br><span style="color:rgb(0,0,128);font-weight:bold;">final </span>CameraSurfaceView cameraView = <span style="color:rgb(0,0,128);font-weight:bold;">new </span>CameraSurfaceView(getApplicationContext());<br> FrameLayout previewFrame = (FrameLayout) findViewById(R.id.<span style="color:rgb(102,14,122);font-style:italic;font-weight:bold;">previewFrame</span>);<br> previewFrame.addView(cameraView);</pre><span style="color:rgb(128,128,0);"></span><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);"> </pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);"></pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);"><span style="background-color:rgb(228,228,255);"> Left</span>.setOnClickListener(<span style="color:rgb(0,0,128);font-weight:bold;">this</span>);<br><span style="color:rgb(102,14,122);font-weight:bold;"> Right</span>.setOnClickListener(<span style="color:rgb(0,0,128);font-weight:bold;">this</span>);</pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);"> </pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);"><span style="color:rgb(128,128,0);">}</span></pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);"><span style="color:rgb(128,128,0);">@Override<br></span><span style="color:rgb(0,0,128);font-weight:bold;">public void </span>onClick(View v) {<br><span style="color:rgb(128,128,128);font-style:italic;">// </span><span style="color:rgb(0,115,191);font-style:italic;font-weight:bold;">TODO Auto-generated method stub<br></span><span style="color:rgb(0,115,191);font-style:italic;font-weight:bold;"> </span><span style="color:rgb(0,0,128);font-weight:bold;">if </span>(v == <span style="color:rgb(102,14,122);font-weight:bold;">Left</span>)<br><span style="color:rgb(0,0,128);font-weight:bold;">if</span>(<span style="color:rgb(102,14,122);font-weight:bold;">status</span>==<span style="color:rgb(0,0,255);">0</span>) <span style="color:rgb(102,14,122);font-weight:bold;">view</span>.startFlipping();<br><span style="color:rgb(0,0,128);font-weight:bold;">if</span>(<span style="color:rgb(102,14,122);font-weight:bold;">status</span>==<span style="color:rgb(0,0,255);">1</span>) {<br><br>.capture(<span style="color:rgb(0,0,128);font-weight:bold;">new </span>Camera.PictureCallback() {<br><span style="color:rgb(0,0,128);font-weight:bold;">public void </span>onPictureTaken(<span style="color:rgb(0,0,128);font-weight:bold;">byte</span>[] data, Camera camera) {<br><span style="color:rgb(0,0,128);font-weight:bold;">try </span>{...} ...</pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);">}</pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);">위에서 만든 카메라뷰 객체를 읽지못하는데요.</pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);">onClick에서 읽는 방법이있을까요?</pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);"> </pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);">로컬 바리에이블이나</pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);">필드 선언하면 NullException으로 터지네요.,</pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);">리스너 아래에 onclick으로 읽을땐 정상적으로 작동합니다.</pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);"> </pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);"></pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);"><span style="color:rgb(0,0,128);font-weight:bold;">final </span>CameraSurfaceView cameraView = <span style="color:rgb(0,0,128);font-weight:bold;">new </span>CameraSurfaceView(getApplicationContext());<br>FrameLayout previewFrame = (FrameLayout) findViewById(R.id.<span style="color:rgb(102,14,122);font-style:italic;font-weight:bold;">previewFrame</span>);<br>previewFrame.addView(cameraView);<br><br><span style="color:rgb(128,128,128);font-style:italic;">// 버튼 이벤트 처리<br></span>Button saveBtn = (Button) findViewById(R.id.<span style="color:rgb(102,14,122);font-style:italic;font-weight:bold;">saveBtn</span>);<br>saveBtn.setOnClickListener(<span style="color:rgb(0,0,128);font-weight:bold;">new </span>View.OnClickListener() {<br><span style="color:rgb(0,0,128);font-weight:bold;">public void </span>onClick(View v) {<br><span style="color:rgb(102,14,122);">cameraView</span>.capture(<span style="color:rgb(0,0,128);font-weight:bold;">new </span>Camera.PictureCallback() {</pre><pre style="color:rgb(0,0,0);font-family:'굴림체';font-size:9pt;background-color:rgb(255,255,255);">이런식으로 말이죠.</pre>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.