Note that there are some explanatory texts on larger screens.

plurals
  1. PONetBeans - Android ImageButton
    primarykey
    data
    text
    <p>I'm having a problem that can not solve. I would like your help.</p> <p>I have an ImageButton that is calling another class, which is not the MainActivity. When I compile the program does not display any error but when I run the emulator and click on ImageButton he gives the following error:</p> <p>"The invalid application INOV (process org.me.teste) has stopped unexpectedly. Please try again."</p> <p>Below is my MainActivity and my other class:</p> <pre><code>package org.me.teste; import android.app.Activity; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.ImageButton; import android.widget.TableLayout; public class MainActivity extends Activity { private TableLayout myTableLayout; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TableLayout myTableLayout = (TableLayout)findViewById(R.id.myTableLayout); ImageButton i = (ImageButton)findViewById(R.id.refributton); i.setImageResource(R.drawable.imagem); i.setBackgroundDrawable(null); i.setAdjustViewBounds (true); i.setOnClickListener(new View.OnClickListener(){ public void onClick(View view) { Intent perirefri = new Intent(org.me.teste.MainActivity.this, PerifericosRefri.class); startActivity(perirefri); } }); } } </code></pre> <p>Follow my class:</p> <pre><code>package org.me.teste; import android.app.Activity; import android.os.Bundle; import android.widget.ImageButton; import android.widget.TableLayout; public class PerifericosRefri extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.perifericosrefri); TableLayout myTableLayout2 = (TableLayout)findViewById(R.id.myTableLayout2); ImageButton i3 = (ImageButton)findViewById(R.id.camerabutton); ImageButton i4 = (ImageButton)findViewById(R.id.barcodebutton); i3.setImageResource(R.drawable.imagem3); i3.setBackgroundDrawable(null); i3.setAdjustViewBounds (true); i4.setImageResource(R.drawable.imagem4); i4.setBackgroundDrawable(null); i4.setAdjustViewBounds (true); } } </code></pre> <p>I am Brazilian and if I made a clerical error, I apologize.</p> <p>Thanks for the help guys!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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