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();

```
`static Toast makeText(Context context, int resId, int duration)`

The problem is that you are passing `5000` as the third parameter to the method. `int duration` is *not* the number of seconds (or milli-seconds) the `Toast` will appear to the user. The `Toast` class requires that you pass only two possible values (which makes sense, because otherwise developers would totally abuse the lengths of toast messages and the applications on the Android market would be totally inconsistent in how they display messages to the user). The two values are:

```
Toast.LENGTH_SHORT 
Constant Value: 0 (0x00000000) 

```

or 

```
Toast.LENGTH_LONG`
Constant Value: 1 (0x00000001)

```

To fix the issue, change the method call to,

```
Toast.makeText(this, "Testing", Toast.LENGTH_LONG).show();

```

---

Also, remember to set your `onClickListener` on your `ImageButton`s (just a shot in the dark).