In the code below, I added a button to the toast, but I am facing two
problems.

1.  The button is not clickable!  onClick is not called when I click on the
button.
2.  If I replace Toast.LENGTH_LONG with a number 10000, the toast does not
stay for 10 seconds.

Is it by design that you can't add any listener to the UI controls on the
toast?
How do you change the duration of how long the toast stays?


[code]

protected void showToast() {
   LayoutInflater vi = (Layout Inflater) getSystemService(Context...);
   View view = vi.inflate (R.layout...., null);

   toast = new Toast(this);
   TextView tv = (TextView)view.findViewById(R.id....);
   tv.setText("blah");
   toast.setView(view);
   toast.setDuration(Toast.LENGTH_LONG);

   Button button = (Button) view.findViewById(R.id....);
   button.setOnClickListener (new Button.OnClickLIstener() {
      public void onClick(View v) {
         // do a few things here before cancel
         toast.cancel();
      }}
   );
   toast.show();

[/code]


Thanks,
J

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to