Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Why do you use two layouts? I'm almost sure that your problem is using <code>findViewById(R.id.false_view)</code> without calling setContentView(R.layout.blabla_whatever), where blabla_whatever.xml contains <code>false_view</code>.</p> <p>Why don't you just do something like:</p> <pre><code>ImageView imageView = (ImageView) findViewById(R.id.image_view); TextView textView = (TextView) findViewById(R.id.textViewGoodPic); if (facesFound &gt; 0){ //face detection code //write the bmp to an output stream, compress textView.setText(R.string.yesFace); imageView.setImageBitmap(bitmap565); }else{ textView.setText(R.string.noFaceFive); imageView.setImageBitmap(bitmap565); } </code></pre> <p>Again... unless you show a completely different layout, you wouldn't need to use different <code>ImageViews</code> nor <code>TextView</code> to show the result.</p> <p>If you insist in having different layouts, make sure to call the <code>setContentView(R.layout.noface_layout)</code> before using the <code>findViewById</code> method.</p> <p><strong>Edit</strong></p> <p>Now I know why you think you need another layout. You can use just one layout though. This is what you can do:</p> <pre><code>OnClickListener editPhoto = new OnClickListener(){ public void onClick(){ // edit photo stuff } }; OnClickListener takePhotoAgain = new OnClickListener(){ public void onClick(){ // take the photo again } }; ImageView imageView = (ImageView) findViewById(R.id.image_view); TextView textView = (TextView) findViewById(R.id.textViewGoodPic); Button actionButton = (Button) findViewById(R.id.some_id); if (facesFound &gt; 0){ //face detection code //write the bmp to an output stream, compress textView.setText(R.string.yesFace); imageView.setImageBitmap(bitmap565); actionButton.setText("Face detected, edit it!"); actionButton.setOnClickListener(editPhoto); }else{ textView.setText(R.string.noFaceFive); imageView.setImageBitmap(bitmap565); actionButton.setText("You are too ugly for me, take another picture!"); actionButton.setOnClickListener(takePhotoAgain); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload