Question: Does anyone know why this program won't show the toast message? 

```
public class Main extends Activity implements OnClickListener{
/** Called when the activity is first created. */

  ImageButton x = (ImageButton) findViewById(R.id.imageButton1);
  ImageButton i = (ImageButton) findViewById(R.id.imageButton2);
  ImageButton question = (ImageButton) findViewById(R.id.imageButton3);

```

I have crated some ImageButons and other elements and created onClick function

```
public void onClick(View v) {
            if(v.getId() == R.id.button1) // this works 
            {
                Intent intent = new Intent(this, Second.class);
                intent.putExtra("thetext", et1.getText().toString());
                intent.putExtra("thesize", et2.getText().toString());
                startActivity(intent);
            }
            if(v.getId() == R.id.imageButton2) // this wont work 
            {
                Toast toastI = Toast.makeText(this, "Testing", 5000);
                toastI.setGravity(Gravity.CENTER, 0, 0);
                toastI.show();
            }

```

When i Click on ImageButton i(after i run program) the toast won't display?

Answer: 
Hope you have set the onclickListener on imagebuttons.. 

```
  i.setOnClickListener(this);

```

try this

```
Toast.makeText(getApplication(), "Testing", 5000).show();

```
First implements View.OnClickListener interface and add listener to each imagebutton like this :

x.setOnClickListener(this);

* for the toast message the code mjst be like this :

Toast.makeText(Main.this,"put your message here",Toast.LENGTH\_LONG).show();