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

```
I think your problem is putting 5000 on the length of the toast. [LENGTH\_LONG](http://developer.android.com/reference/android/widget/Toast.html#LENGTH_LONG) and [LENGTH\_SHORT](http://developer.android.com/reference/android/widget/Toast.html#LENGTH_SHORT) have values 1 and 0 so they are used as flags. So I don't know what Would happen if you put 5000 (probably nothing). Also on the java doc they say you should put or or the other. So use one or the other. 

> 
> public static Toast makeText (Context context, CharSequence text, int
>  duration) Since: API Level 1 Make a standard toast that just
>  contains a text view.
> 
> 
> Parameters context The context to use. Usually your Application or
>  Activity object. text The text to show. Can be formatted text. 
>  duration How long to display the message. Either LENGTH\_SHORT or
>  LENGTH\_LONG
> 
> 
>