[android-developers] Re: Android Toast Duration

2009-09-21 Thread alkar

I've been trying to make a custom Toast-like Dialog and went with the
theme-d constructor, but for some reason the view expands from top to
bottom and the theme looks all weird.

Also, Jason, if you made it already, could you tell me how you managed
to position the Toast-like Dialog near the bottom of the screen, just
as a normal toast does?

Finally, is it possible to duplicate the non-selectable, non-
interfering-with-UI behaviour of the Toast? I thought it would be done
by setting the Dialog non-focusable, but apparantly can't do that.

Thanks in advance,
alkar

On Sep 21, 5:00 am, Dianne Hackborn hack...@android.com wrote:
 Dialog has a constructor taking a theme.

 On Sun, Sep 20, 2009 at 4:07 PM, Jason Van Anden
 jason.van.an...@gmail.comwrote:





  I was hoping I could simply apply the theme in xml rather than have to
  create an Activity and apply it in onCreate.

  Thanks for clearing that up.

  Jason

  On Sat, Sep 19, 2009 at 3:08 PM, Dianne Hackborn hack...@android.com
  wrote:
   (Btw, Api demos has one or two examples of creating custom themed
  dialogs, I
   believe in the app section.)

   On Sat, Sep 19, 2009 at 12:07 PM, Dianne Hackborn hack...@android.com
   wrote:

   You are making a theme, which is a kind of style that applies to an
  entire
   context, but just a UI element.  You need to use it as the theme for an
   activity take or the second argument to the Dialog constructor, however
  you
   are creating the window.

   On Sat, Sep 19, 2009 at 11:26 AM, Jason Van Anden
   jason.van.an...@gmail.com wrote:

   Dear Dianne et al,

   My feedback was meant as constructive criticism in general -
   definitely not as a dis directed at you.  I believe that an example is
   worth a thousand words - it works or it don't.

   I appreciate the time you spend with the board.  I make it a point to
   star pretty much anything you write here so I can review it later.
   This particular thread was recalled exactly because of this.  Your
   suggestion of altering the style of a dialog seems perfect for a step
   by step walk through of an app - which is what I am working on.
   Clearly we need more generous experts like yourself helping Android
   along.

   That being said ... I thought I had figured it out - but I am still
   stumped.  If someone out there could help, it will help save at least
   one Android developer's weekend ...

   Here is my code:

   Within my theme.xml I have:

   resources
      style name=ToastyDialog parent=android:Theme
          item
   name=android:windowBackground@android:drawable/toast_frame/item
          item

  name=android:windowAnimationStyle@android:style/Animation.Toast/item
      /style
   resources

   Within my dialog layout I have:

   ?xml version=1.0 encoding=utf-8?

   LinearLayout xmlns:android=
 http://schemas.android.com/apk/res/android;
      android:layout_width=fill_parent
      android:layout_height=wrap_content
      android:orientation=vertical
      style=@style/ToastyDialog

          TextView android:id=@+id/TextView01
                    android:layout_width=wrap_content
                    android:layout_height=wrap_content
                    android:text=@string/hello_world

      /TextView
   /LinearLayout

   NOTE: The Eclipse interface gives you a choice to pick a theme, and my
   theme does appear.  Thing is, it does not write it in the XML.  I
   added the style tag based upon this post:

 http://brainflush.wordpress.com/2009/03/15/understanding-android-them...

   I sincerely hope that I am making a stupid, obvious mistake.

   Thank You,
   Jason

   On Sat, Sep 19, 2009 at 1:25 PM, Dianne Hackborn hack...@android.com
   wrote:
On Sat, Sep 19, 2009 at 9:47 AM, Jason Van Anden
jason.van.an...@gmail.com
wrote:

There are a few threads on this topic that offer advice where an
example would be more useful (IMHO).

I post to this list in my (oh so copious) spare time; I can either
  post
answers that I can do quickly, or just not post at all if it is going
to
take me time to put together and test an example.  Your choice.
--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time
to
provide private support, and so won't reply to such e-mails.  All
  such
questions should be posted on public forums, where I and others can
  see
and
answer them.

   --
   Dianne Hackborn
   Android framework engineer
   hack...@android.com

   Note: please don't send private questions to me, as I don't have time to
   provide private support, and so won't reply to such e-mails.  All such
   questions should be posted on public forums, where I and others can see
  and
   answer them.

   --
   Dianne Hackborn
   Android framework engineer
   hack...@android.com

   Note: please don't send private questions to me, as I don't have time to
   provide private support, and so won't reply to such 

[android-developers] Re: Android Toast Duration

2009-09-20 Thread Jason Van Anden

I was hoping I could simply apply the theme in xml rather than have to
create an Activity and apply it in onCreate.

Thanks for clearing that up.

Jason

On Sat, Sep 19, 2009 at 3:08 PM, Dianne Hackborn hack...@android.com wrote:
 (Btw, Api demos has one or two examples of creating custom themed dialogs, I
 believe in the app section.)

 On Sat, Sep 19, 2009 at 12:07 PM, Dianne Hackborn hack...@android.com
 wrote:

 You are making a theme, which is a kind of style that applies to an entire
 context, but just a UI element.  You need to use it as the theme for an
 activity take or the second argument to the Dialog constructor, however you
 are creating the window.

 On Sat, Sep 19, 2009 at 11:26 AM, Jason Van Anden
 jason.van.an...@gmail.com wrote:

 Dear Dianne et al,

 My feedback was meant as constructive criticism in general -
 definitely not as a dis directed at you.  I believe that an example is
 worth a thousand words - it works or it don't.

 I appreciate the time you spend with the board.  I make it a point to
 star pretty much anything you write here so I can review it later.
 This particular thread was recalled exactly because of this.  Your
 suggestion of altering the style of a dialog seems perfect for a step
 by step walk through of an app - which is what I am working on.
 Clearly we need more generous experts like yourself helping Android
 along.

 That being said ... I thought I had figured it out - but I am still
 stumped.  If someone out there could help, it will help save at least
 one Android developer's weekend ...

 Here is my code:

 Within my theme.xml I have:

 resources
    style name=ToastyDialog parent=android:Theme
        item
 name=android:windowBackground@android:drawable/toast_frame/item
        item
 name=android:windowAnimationStyle@android:style/Animation.Toast/item
    /style
 resources

 Within my dialog layout I have:

 ?xml version=1.0 encoding=utf-8?

 LinearLayout xmlns:android=http://schemas.android.com/apk/res/android;
    android:layout_width=fill_parent
    android:layout_height=wrap_content
    android:orientation=vertical
    style=@style/ToastyDialog
    

        TextView android:id=@+id/TextView01
                  android:layout_width=wrap_content
                  android:layout_height=wrap_content
                  android:text=@string/hello_world
                  

    /TextView
 /LinearLayout

 NOTE: The Eclipse interface gives you a choice to pick a theme, and my
 theme does appear.  Thing is, it does not write it in the XML.  I
 added the style tag based upon this post:


 http://brainflush.wordpress.com/2009/03/15/understanding-android-themes-and-styles/

 I sincerely hope that I am making a stupid, obvious mistake.

 Thank You,
 Jason


 On Sat, Sep 19, 2009 at 1:25 PM, Dianne Hackborn hack...@android.com
 wrote:
  On Sat, Sep 19, 2009 at 9:47 AM, Jason Van Anden
  jason.van.an...@gmail.com
  wrote:
 
  There are a few threads on this topic that offer advice where an
  example would be more useful (IMHO).
 
  I post to this list in my (oh so copious) spare time; I can either post
  answers that I can do quickly, or just not post at all if it is going
  to
  take me time to put together and test an example.  Your choice.
  --
  Dianne Hackborn
  Android framework engineer
  hack...@android.com
 
  Note: please don't send private questions to me, as I don't have time
  to
  provide private support, and so won't reply to such e-mails.  All such
  questions should be posted on public forums, where I and others can see
  and
  answer them.
 
 
  
 





 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.




 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.


 


--~--~-~--~~~---~--~~
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-09-20 Thread Dianne Hackborn
Dialog has a constructor taking a theme.

On Sun, Sep 20, 2009 at 4:07 PM, Jason Van Anden
jason.van.an...@gmail.comwrote:


 I was hoping I could simply apply the theme in xml rather than have to
 create an Activity and apply it in onCreate.

 Thanks for clearing that up.

 Jason

 On Sat, Sep 19, 2009 at 3:08 PM, Dianne Hackborn hack...@android.com
 wrote:
  (Btw, Api demos has one or two examples of creating custom themed
 dialogs, I
  believe in the app section.)
 
  On Sat, Sep 19, 2009 at 12:07 PM, Dianne Hackborn hack...@android.com
  wrote:
 
  You are making a theme, which is a kind of style that applies to an
 entire
  context, but just a UI element.  You need to use it as the theme for an
  activity take or the second argument to the Dialog constructor, however
 you
  are creating the window.
 
  On Sat, Sep 19, 2009 at 11:26 AM, Jason Van Anden
  jason.van.an...@gmail.com wrote:
 
  Dear Dianne et al,
 
  My feedback was meant as constructive criticism in general -
  definitely not as a dis directed at you.  I believe that an example is
  worth a thousand words - it works or it don't.
 
  I appreciate the time you spend with the board.  I make it a point to
  star pretty much anything you write here so I can review it later.
  This particular thread was recalled exactly because of this.  Your
  suggestion of altering the style of a dialog seems perfect for a step
  by step walk through of an app - which is what I am working on.
  Clearly we need more generous experts like yourself helping Android
  along.
 
  That being said ... I thought I had figured it out - but I am still
  stumped.  If someone out there could help, it will help save at least
  one Android developer's weekend ...
 
  Here is my code:
 
  Within my theme.xml I have:
 
  resources
 style name=ToastyDialog parent=android:Theme
 item
  name=android:windowBackground@android:drawable/toast_frame/item
 item
 
 name=android:windowAnimationStyle@android:style/Animation.Toast/item
 /style
  resources
 
  Within my dialog layout I have:
 
  ?xml version=1.0 encoding=utf-8?
 
  LinearLayout xmlns:android=
 http://schemas.android.com/apk/res/android;
 android:layout_width=fill_parent
 android:layout_height=wrap_content
 android:orientation=vertical
 style=@style/ToastyDialog
 
 
 TextView android:id=@+id/TextView01
   android:layout_width=wrap_content
   android:layout_height=wrap_content
   android:text=@string/hello_world
   
 
 /TextView
  /LinearLayout
 
  NOTE: The Eclipse interface gives you a choice to pick a theme, and my
  theme does appear.  Thing is, it does not write it in the XML.  I
  added the style tag based upon this post:
 
 
 
 http://brainflush.wordpress.com/2009/03/15/understanding-android-themes-and-styles/
 
  I sincerely hope that I am making a stupid, obvious mistake.
 
  Thank You,
  Jason
 
 
  On Sat, Sep 19, 2009 at 1:25 PM, Dianne Hackborn hack...@android.com
  wrote:
   On Sat, Sep 19, 2009 at 9:47 AM, Jason Van Anden
   jason.van.an...@gmail.com
   wrote:
  
   There are a few threads on this topic that offer advice where an
   example would be more useful (IMHO).
  
   I post to this list in my (oh so copious) spare time; I can either
 post
   answers that I can do quickly, or just not post at all if it is going
   to
   take me time to put together and test an example.  Your choice.
   --
   Dianne Hackborn
   Android framework engineer
   hack...@android.com
  
   Note: please don't send private questions to me, as I don't have time
   to
   provide private support, and so won't reply to such e-mails.  All
 such
   questions should be posted on public forums, where I and others can
 see
   and
   answer them.
  
  
   
  
 
 
 
 
 
  --
  Dianne Hackborn
  Android framework engineer
  hack...@android.com
 
  Note: please don't send private questions to me, as I don't have time to
  provide private support, and so won't reply to such e-mails.  All such
  questions should be posted on public forums, where I and others can see
 and
  answer them.
 
 
 
 
  --
  Dianne Hackborn
  Android framework engineer
  hack...@android.com
 
  Note: please don't send private questions to me, as I don't have time to
  provide private support, and so won't reply to such e-mails.  All such
  questions should be posted on public forums, where I and others can see
 and
  answer them.
 
 
  
 

 



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~-~--~~~---~--~~
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] Re: Android Toast Duration

2009-09-19 Thread Jason Van Anden

On Thu, Jul 23, 2009 at 6:34 PM, Dianne Hackborn hack...@android.com wrote:
 It sounds like you are abusing toasts.  How about just showing your own
 dialog that is set up to not get focus or be touchable?  You can use this
 background to make it look like a toast:

 http://developer.android.com/reference/android/R.drawable.html#toast_frame

 And this animation style for the same fade effect:

 http://developer.android.com/reference/android/R.style.html#Animation_Toast


I am trying to do this and confused about the syntax for accessing the
toast_frame via theme xml.  Would appreciate example.

Thank You,
Jason



 On Thu, Jul 23, 2009 at 8:17 AM, Mohamed Amir mohamed.a...@gmail.com
 wrote:

 Is there a way to make the Toast last for longer time?

 I have tried this code

                        Toast t = new Toast(this);
                        View v = View.inflate(this, R.toast_layout, null);
                        t.setView(v);
                        t.setDuration(Toast.LENGTH_LONG);
                        t.show();
                        t.show();
                        t.show();

 By calling show() method more than once, I hoped this would give a
 similar effect to lasting for longer time with some flickering, but I
 didn't see any difference.
 Is there some limit to the number of times that show() method can be
 called on the same Toast? e.g. just once per toast instance and
 further calling has no effect?

 Any ideas to increase that duration?

 Thank you.




 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.


 


--~--~-~--~~~---~--~~
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-09-19 Thread Jason Van Anden

I am close to sorting this out ... I will post my code when I know I got it.

There are a few threads on this topic that offer advice where an
example would be more useful (IMHO).

j

On Sat, Sep 19, 2009 at 12:11 PM, Jason Van Anden
jason.van.an...@gmail.com wrote:
 On Thu, Jul 23, 2009 at 6:34 PM, Dianne Hackborn hack...@android.com wrote:
 It sounds like you are abusing toasts.  How about just showing your own
 dialog that is set up to not get focus or be touchable?  You can use this
 background to make it look like a toast:

 http://developer.android.com/reference/android/R.drawable.html#toast_frame

 And this animation style for the same fade effect:

 http://developer.android.com/reference/android/R.style.html#Animation_Toast


 I am trying to do this and confused about the syntax for accessing the
 toast_frame via theme xml.  Would appreciate example.

 Thank You,
 Jason



 On Thu, Jul 23, 2009 at 8:17 AM, Mohamed Amir mohamed.a...@gmail.com
 wrote:

 Is there a way to make the Toast last for longer time?

 I have tried this code

                        Toast t = new Toast(this);
                        View v = View.inflate(this, R.toast_layout, null);
                        t.setView(v);
                        t.setDuration(Toast.LENGTH_LONG);
                        t.show();
                        t.show();
                        t.show();

 By calling show() method more than once, I hoped this would give a
 similar effect to lasting for longer time with some flickering, but I
 didn't see any difference.
 Is there some limit to the number of times that show() method can be
 called on the same Toast? e.g. just once per toast instance and
 further calling has no effect?

 Any ideas to increase that duration?

 Thank you.




 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.


 



--~--~-~--~~~---~--~~
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-09-19 Thread Dianne Hackborn
On Sat, Sep 19, 2009 at 9:47 AM, Jason Van Anden
jason.van.an...@gmail.comwrote:

 There are a few threads on this topic that offer advice where an
 example would be more useful (IMHO).


I post to this list in my (oh so copious) spare time; I can either post
answers that I can do quickly, or just not post at all if it is going to
take me time to put together and test an example.  Your choice.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~-~--~~~---~--~~
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-09-19 Thread Jason Van Anden

Dear Dianne et al,

My feedback was meant as constructive criticism in general -
definitely not as a dis directed at you.  I believe that an example is
worth a thousand words - it works or it don't.

I appreciate the time you spend with the board.  I make it a point to
star pretty much anything you write here so I can review it later.
This particular thread was recalled exactly because of this.  Your
suggestion of altering the style of a dialog seems perfect for a step
by step walk through of an app - which is what I am working on.
Clearly we need more generous experts like yourself helping Android
along.

That being said ... I thought I had figured it out - but I am still
stumped.  If someone out there could help, it will help save at least
one Android developer's weekend ...

Here is my code:

Within my theme.xml I have:

resources
style name=ToastyDialog parent=android:Theme
item 
name=android:windowBackground@android:drawable/toast_frame/item
item 
name=android:windowAnimationStyle@android:style/Animation.Toast/item
/style
resources

Within my dialog layout I have:

?xml version=1.0 encoding=utf-8?

LinearLayout xmlns:android=http://schemas.android.com/apk/res/android;
android:layout_width=fill_parent
android:layout_height=wrap_content
android:orientation=vertical
style=@style/ToastyDialog


TextView android:id=@+id/TextView01
  android:layout_width=wrap_content
  android:layout_height=wrap_content
  android:text=@string/hello_world
  

/TextView
/LinearLayout

NOTE: The Eclipse interface gives you a choice to pick a theme, and my
theme does appear.  Thing is, it does not write it in the XML.  I
added the style tag based upon this post:

http://brainflush.wordpress.com/2009/03/15/understanding-android-themes-and-styles/

I sincerely hope that I am making a stupid, obvious mistake.

Thank You,
Jason


On Sat, Sep 19, 2009 at 1:25 PM, Dianne Hackborn hack...@android.com wrote:
 On Sat, Sep 19, 2009 at 9:47 AM, Jason Van Anden jason.van.an...@gmail.com
 wrote:

 There are a few threads on this topic that offer advice where an
 example would be more useful (IMHO).

 I post to this list in my (oh so copious) spare time; I can either post
 answers that I can do quickly, or just not post at all if it is going to
 take me time to put together and test an example.  Your choice.
 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.


 


--~--~-~--~~~---~--~~
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-09-19 Thread Dianne Hackborn
You are making a theme, which is a kind of style that applies to an entire
context, but just a UI element.  You need to use it as the theme for an
activity take or the second argument to the Dialog constructor, however you
are creating the window.

On Sat, Sep 19, 2009 at 11:26 AM, Jason Van Anden jason.van.an...@gmail.com
 wrote:


 Dear Dianne et al,

 My feedback was meant as constructive criticism in general -
 definitely not as a dis directed at you.  I believe that an example is
 worth a thousand words - it works or it don't.

 I appreciate the time you spend with the board.  I make it a point to
 star pretty much anything you write here so I can review it later.
 This particular thread was recalled exactly because of this.  Your
 suggestion of altering the style of a dialog seems perfect for a step
 by step walk through of an app - which is what I am working on.
 Clearly we need more generous experts like yourself helping Android
 along.

 That being said ... I thought I had figured it out - but I am still
 stumped.  If someone out there could help, it will help save at least
 one Android developer's weekend ...

 Here is my code:

 Within my theme.xml I have:

 resources
style name=ToastyDialog parent=android:Theme
item
 name=android:windowBackground@android:drawable/toast_frame/item
item
 name=android:windowAnimationStyle@android:style/Animation.Toast/item
/style
 resources

 Within my dialog layout I have:

 ?xml version=1.0 encoding=utf-8?

 LinearLayout xmlns:android=http://schemas.android.com/apk/res/android;
android:layout_width=fill_parent
android:layout_height=wrap_content
android:orientation=vertical
style=@style/ToastyDialog


TextView android:id=@+id/TextView01
  android:layout_width=wrap_content
  android:layout_height=wrap_content
  android:text=@string/hello_world
  

/TextView
 /LinearLayout

 NOTE: The Eclipse interface gives you a choice to pick a theme, and my
 theme does appear.  Thing is, it does not write it in the XML.  I
 added the style tag based upon this post:


 http://brainflush.wordpress.com/2009/03/15/understanding-android-themes-and-styles/

 I sincerely hope that I am making a stupid, obvious mistake.

 Thank You,
 Jason


 On Sat, Sep 19, 2009 at 1:25 PM, Dianne Hackborn hack...@android.com
 wrote:
  On Sat, Sep 19, 2009 at 9:47 AM, Jason Van Anden 
 jason.van.an...@gmail.com
  wrote:
 
  There are a few threads on this topic that offer advice where an
  example would be more useful (IMHO).
 
  I post to this list in my (oh so copious) spare time; I can either post
  answers that I can do quickly, or just not post at all if it is going to
  take me time to put together and test an example.  Your choice.
  --
  Dianne Hackborn
  Android framework engineer
  hack...@android.com
 
  Note: please don't send private questions to me, as I don't have time to
  provide private support, and so won't reply to such e-mails.  All such
  questions should be posted on public forums, where I and others can see
 and
  answer them.
 
 
  
 

 



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~-~--~~~---~--~~
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-09-19 Thread Dianne Hackborn
(Btw, Api demos has one or two examples of creating custom themed dialogs, I
believe in the app section.)

On Sat, Sep 19, 2009 at 12:07 PM, Dianne Hackborn hack...@android.comwrote:

 You are making a theme, which is a kind of style that applies to an entire
 context, but just a UI element.  You need to use it as the theme for an
 activity take or the second argument to the Dialog constructor, however you
 are creating the window.


 On Sat, Sep 19, 2009 at 11:26 AM, Jason Van Anden 
 jason.van.an...@gmail.com wrote:


 Dear Dianne et al,

 My feedback was meant as constructive criticism in general -
 definitely not as a dis directed at you.  I believe that an example is
 worth a thousand words - it works or it don't.

 I appreciate the time you spend with the board.  I make it a point to
 star pretty much anything you write here so I can review it later.
 This particular thread was recalled exactly because of this.  Your
 suggestion of altering the style of a dialog seems perfect for a step
 by step walk through of an app - which is what I am working on.
 Clearly we need more generous experts like yourself helping Android
 along.

 That being said ... I thought I had figured it out - but I am still
 stumped.  If someone out there could help, it will help save at least
 one Android developer's weekend ...

 Here is my code:

 Within my theme.xml I have:

 resources
style name=ToastyDialog parent=android:Theme
item
 name=android:windowBackground@android:drawable/toast_frame/item
item
 name=android:windowAnimationStyle@android:style/Animation.Toast/item
/style
 resources

 Within my dialog layout I have:

 ?xml version=1.0 encoding=utf-8?

 LinearLayout xmlns:android=http://schemas.android.com/apk/res/android;
android:layout_width=fill_parent
android:layout_height=wrap_content
android:orientation=vertical
style=@style/ToastyDialog


TextView android:id=@+id/TextView01
  android:layout_width=wrap_content
  android:layout_height=wrap_content
  android:text=@string/hello_world
  

/TextView
 /LinearLayout

 NOTE: The Eclipse interface gives you a choice to pick a theme, and my
 theme does appear.  Thing is, it does not write it in the XML.  I
 added the style tag based upon this post:


 http://brainflush.wordpress.com/2009/03/15/understanding-android-themes-and-styles/

 I sincerely hope that I am making a stupid, obvious mistake.

 Thank You,
 Jason


 On Sat, Sep 19, 2009 at 1:25 PM, Dianne Hackborn hack...@android.com
 wrote:
  On Sat, Sep 19, 2009 at 9:47 AM, Jason Van Anden 
 jason.van.an...@gmail.com
  wrote:
 
  There are a few threads on this topic that offer advice where an
  example would be more useful (IMHO).
 
  I post to this list in my (oh so copious) spare time; I can either post
  answers that I can do quickly, or just not post at all if it is going to
  take me time to put together and test an example.  Your choice.
  --
  Dianne Hackborn
  Android framework engineer
  hack...@android.com
 
  Note: please don't send private questions to me, as I don't have time to
  provide private support, and so won't reply to such e-mails.  All such
  questions should be posted on public forums, where I and others can see
 and
  answer them.
 
 
  
 

 



 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.




-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~-~--~~~---~--~~
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-07-29 Thread saptarshi chatterjee

I have found a stupid but effective way . I really wanted to see a
particular lengthy error message  . and I found this
Idea...

try{
-

}

catch(Exception e) {
Toast t1,t2,t3,t4,t5;
   t1=Toast.makeText(this, i+e.toString(),Toast.LENGTH_LONG);
   t2=Toast.makeText(this, i+e.toString(),Toast.LENGTH_LONG);
   t3=Toast.makeText(this, i+e.toString(),Toast.LENGTH_LONG);
   t4=Toast.makeText(this, i+e.toString(),Toast.LENGTH_LONG);
   t5=Toast.makeText(this, i+e.toString(),Toast.LENGTH_LONG);
   t1.show();
   t2.show();
   t3.show();
   t4.show();
   t5.show();
}


I know it's very stupid but it works none the less.


On Jul 27, 2:14 pm, skink psk...@gmail.com wrote:
  Any ideas to increase that duration?

 as Dianne said, use Dialog for that but if you really, really, really
 want Toast for that there is a dirty, tricky workaround (hack) of
 showing the same Toast in say two seconds after the first time Toast
 was shown.

 something like this:

 postDelayed(showToastAgainRunnable, 2000)
--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-07-27 Thread Sydney

Toast.LENGTH_LONG and Toast.LENGTH_SHORT are not numbers of
milliseconds. If you print out the values you get:

Toast.LENGTH_LONG = 1
Toast.LENGTH_SHORT = 0

If you give a value other than 1 or 0, it seems to default to
LENGTH_SHORT.

Toast.LENGTH_LONG is ~4 seconds
Toast.LENGTH_SHORT  is ~2.5 seconds

Based on using a stopwatch and watching the emulator running on my
laptop.

On Jul 24, 3:13 pm, Scott scott.mikoly...@gmail.com wrote:
 Toast.LENGTH_LONG is only a constant number of milliseconds.  You can
 use any number of milliseconds if you like but there might be a
 maximum.

 Example:
 t.setDuration();

 Scott

 On Jul 23, 10:31 pm, Mohamed Amir mohamed.a...@gmail.com wrote:

  Thank you for all those who replied.

  But Toast is the only UI component I could find that appears over the
  incoming call dialog.  I need to show some information when an
  incoming call arrives.  This is why I am using the Toast.

  On Jul 24, 1:34 am, Dianne Hackborn hack...@android.com wrote:

   It sounds like you are abusing toasts.  How about just showing your own
   dialog that is set up to not get focus or be touchable?  You can use this
   background to make it look like a toast:

  http://developer.android.com/reference/android/R.drawable.html#toast_...

   And this animation style for the same fade effect:

  http://developer.android.com/reference/android/R.style.html#Animation...

   On Thu, Jul 23, 2009 at 8:17 AM, Mohamed Amir 
   mohamed.a...@gmail.comwrote:

Is there a way to make the Toast last for longer time?

I have tried this code

                       Toast t = new Toast(this);
                       View v = View.inflate(this, R.toast_layout, 
null);
                       t.setView(v);
                       t.setDuration(Toast.LENGTH_LONG);
                       t.show();
                       t.show();
                       t.show();

By calling show() method more than once, I hoped this would give a
similar effect to lasting for longer time with some flickering, but I
didn't see any difference.
Is there some limit to the number of times that show() method can be
called on the same Toast? e.g. just once per toast instance and
further calling has no effect?

Any ideas to increase that duration?

Thank you.

   --
   Dianne Hackborn
   Android framework engineer
   hack...@android.com

   Note: please don't send private questions to me, as I don't have time to
   provide private support, and so won't reply to such e-mails.  All such
   questions should be posted on public forums, where I and others can see 
   and
   answer them.
--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-07-27 Thread Urs Grob

actually its 3.5 seconds and 2 seconds:

http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=services/java/com/android/server/NotificationManagerService.java#l74

-- Urs

On Mon, Jul 27, 2009 at 11:02 AM, Sydneysydney.p...@gmail.com wrote:

 Toast.LENGTH_LONG and Toast.LENGTH_SHORT are not numbers of
 milliseconds. If you print out the values you get:

 Toast.LENGTH_LONG = 1
 Toast.LENGTH_SHORT = 0

 If you give a value other than 1 or 0, it seems to default to
 LENGTH_SHORT.

 Toast.LENGTH_LONG is ~4 seconds
 Toast.LENGTH_SHORT  is ~2.5 seconds

 Based on using a stopwatch and watching the emulator running on my
 laptop.

 On Jul 24, 3:13 pm, Scott scott.mikoly...@gmail.com wrote:
 Toast.LENGTH_LONG is only a constant number of milliseconds.  You can
 use any number of milliseconds if you like but there might be a
 maximum.

 Example:
 t.setDuration();

 Scott

 On Jul 23, 10:31 pm, Mohamed Amir mohamed.a...@gmail.com wrote:

  Thank you for all those who replied.

  But Toast is the only UI component I could find that appears over the
  incoming call dialog.  I need to show some information when an
  incoming call arrives.  This is why I am using the Toast.

  On Jul 24, 1:34 am, Dianne Hackborn hack...@android.com wrote:

   It sounds like you are abusing toasts.  How about just showing your own
   dialog that is set up to not get focus or be touchable?  You can use this
   background to make it look like a toast:

  http://developer.android.com/reference/android/R.drawable.html#toast_...

   And this animation style for the same fade effect:

  http://developer.android.com/reference/android/R.style.html#Animation...

   On Thu, Jul 23, 2009 at 8:17 AM, Mohamed Amir 
   mohamed.a...@gmail.comwrote:

Is there a way to make the Toast last for longer time?

I have tried this code

   Toast t = new Toast(this);
   View v = View.inflate(this, R.toast_layout, 
null);
   t.setView(v);
   t.setDuration(Toast.LENGTH_LONG);
   t.show();
   t.show();
   t.show();

By calling show() method more than once, I hoped this would give a
similar effect to lasting for longer time with some flickering, but I
didn't see any difference.
Is there some limit to the number of times that show() method can be
called on the same Toast? e.g. just once per toast instance and
further calling has no effect?

Any ideas to increase that duration?

Thank you.

   --
   Dianne Hackborn
   Android framework engineer
   hack...@android.com

   Note: please don't send private questions to me, as I don't have time to
   provide private support, and so won't reply to such e-mails.  All such
   questions should be posted on public forums, where I and others can see 
   and
   answer them.
 


--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-07-27 Thread skink

 Any ideas to increase that duration?

as Dianne said, use Dialog for that but if you really, really, really
want Toast for that there is a dirty, tricky workaround (hack) of
showing the same Toast in say two seconds after the first time Toast
was shown.

something like this:

postDelayed(showToastAgainRunnable, 2000)
--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-07-26 Thread Scott

Toast.LENGTH_LONG is only a constant number of milliseconds.  You can
use any number of milliseconds if you like but there might be a
maximum.

Example:
t.setDuration();

Scott

On Jul 23, 10:31 pm, Mohamed Amir mohamed.a...@gmail.com wrote:
 Thank you for all those who replied.

 But Toast is the only UI component I could find that appears over the
 incoming call dialog.  I need to show some information when an
 incoming call arrives.  This is why I am using the Toast.

 On Jul 24, 1:34 am, Dianne Hackborn hack...@android.com wrote:

  It sounds like you are abusing toasts.  How about just showing your own
  dialog that is set up to not get focus or be touchable?  You can use this
  background to make it look like a toast:

 http://developer.android.com/reference/android/R.drawable.html#toast_...

  And this animation style for the same fade effect:

 http://developer.android.com/reference/android/R.style.html#Animation...

  On Thu, Jul 23, 2009 at 8:17 AM, Mohamed Amir mohamed.a...@gmail.comwrote:

   Is there a way to make the Toast last for longer time?

   I have tried this code

                          Toast t = new Toast(this);
                          View v = View.inflate(this, R.toast_layout, null);
                          t.setView(v);
                          t.setDuration(Toast.LENGTH_LONG);
                          t.show();
                          t.show();
                          t.show();

   By calling show() method more than once, I hoped this would give a
   similar effect to lasting for longer time with some flickering, but I
   didn't see any difference.
   Is there some limit to the number of times that show() method can be
   called on the same Toast? e.g. just once per toast instance and
   further calling has no effect?

   Any ideas to increase that duration?

   Thank you.

  --
  Dianne Hackborn
  Android framework engineer
  hack...@android.com

  Note: please don't send private questions to me, as I don't have time to
  provide private support, and so won't reply to such e-mails.  All such
  questions should be posted on public forums, where I and others can see and
  answer them.



--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-07-24 Thread Mohamed Amir

Thank you for all those who replied.

But Toast is the only UI component I could find that appears over the
incoming call dialog.  I need to show some information when an
incoming call arrives.  This is why I am using the Toast.




On Jul 24, 1:34 am, Dianne Hackborn hack...@android.com wrote:
 It sounds like you are abusing toasts.  How about just showing your own
 dialog that is set up to not get focus or be touchable?  You can use this
 background to make it look like a toast:

 http://developer.android.com/reference/android/R.drawable.html#toast_...

 And this animation style for the same fade effect:

 http://developer.android.com/reference/android/R.style.html#Animation...

 On Thu, Jul 23, 2009 at 8:17 AM, Mohamed Amir mohamed.a...@gmail.comwrote:







  Is there a way to make the Toast last for longer time?

  I have tried this code

                         Toast t = new Toast(this);
                         View v = View.inflate(this, R.toast_layout, null);
                         t.setView(v);
                         t.setDuration(Toast.LENGTH_LONG);
                         t.show();
                         t.show();
                         t.show();

  By calling show() method more than once, I hoped this would give a
  similar effect to lasting for longer time with some flickering, but I
  didn't see any difference.
  Is there some limit to the number of times that show() method can be
  called on the same Toast? e.g. just once per toast instance and
  further calling has no effect?

  Any ideas to increase that duration?

  Thank you.

 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.
--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-07-23 Thread Kent Loobey
On Thursday 23 July 2009 08:17:25 Mohamed Amir wrote:
 Is there a way to make the Toast last for longer time?

 I have tried this code

   Toast t = new Toast(this);
   View v = View.inflate(this, R.toast_layout, null);
   t.setView(v);
   t.setDuration(Toast.LENGTH_LONG);
   t.show();
   t.show();
   t.show();

 By calling show() method more than once, I hoped this would give a
 similar effect to lasting for longer time with some flickering, but I
 didn't see any difference.
 Is there some limit to the number of times that show() method can be
 called on the same Toast? e.g. just once per toast instance and
 further calling has no effect?

 Any ideas to increase that duration?

Toast.makeText(mContext, Some comment goes here., 4);


 Thank you.
 

--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-07-23 Thread Marco Nelissen

On Thu, Jul 23, 2009 at 11:19 AM, Kent Loobey k...@uoregon.edu wrote:

 On Thursday 23 July 2009 08:17:25 Mohamed Amir wrote:
  Is there a way to make the Toast last for longer time?
 
  I have tried this code
 
  Toast t = new Toast(this);
  View v = View.inflate(this, R.toast_layout, null);
  t.setView(v);
  t.setDuration(Toast.LENGTH_LONG);
  t.show();
  t.show();
  t.show();
 
  By calling show() method more than once, I hoped this would give a
  similar effect to lasting for longer time with some flickering, but I
  didn't see any difference.
  Is there some limit to the number of times that show() method can be
  called on the same Toast? e.g. just once per toast instance and
  further calling has no effect?
 
  Any ideas to increase that duration?

 Toast.makeText(mContext, Some comment goes here., 4);

That won't work, because the duration parameter is expressed in
milliseconds, but as one of two constants.
That being said, toasts are meant to be transient. If you need
something on screen for an extended period of time, use an activity or
dialog.

--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-07-23 Thread Marco Nelissen

On Thu, Jul 23, 2009 at 3:28 PM, Marco Nelissenmarc...@android.com wrote:
 On Thu, Jul 23, 2009 at 11:19 AM, Kent Loobey k...@uoregon.edu wrote:

 On Thursday 23 July 2009 08:17:25 Mohamed Amir wrote:
  Is there a way to make the Toast last for longer time?
 
  I have tried this code
 
  Toast t = new Toast(this);
  View v = View.inflate(this, R.toast_layout, null);
  t.setView(v);
  t.setDuration(Toast.LENGTH_LONG);
  t.show();
  t.show();
  t.show();
 
  By calling show() method more than once, I hoped this would give a
  similar effect to lasting for longer time with some flickering, but I
  didn't see any difference.
  Is there some limit to the number of times that show() method can be
  called on the same Toast? e.g. just once per toast instance and
  further calling has no effect?
 
  Any ideas to increase that duration?

 Toast.makeText(mContext, Some comment goes here., 4);

 That won't work, because the duration parameter is expressed in

I meant is NOT expressed, of course.

 milliseconds, but as one of two constants.
 That being said, toasts are meant to be transient. If you need
 something on screen for an extended period of time, use an activity or
 dialog.


--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Toast Duration

2009-07-23 Thread Dianne Hackborn
It sounds like you are abusing toasts.  How about just showing your own
dialog that is set up to not get focus or be touchable?  You can use this
background to make it look like a toast:

http://developer.android.com/reference/android/R.drawable.html#toast_frame

And this animation style for the same fade effect:

http://developer.android.com/reference/android/R.style.html#Animation_Toast

On Thu, Jul 23, 2009 at 8:17 AM, Mohamed Amir mohamed.a...@gmail.comwrote:


 Is there a way to make the Toast last for longer time?

 I have tried this code

Toast t = new Toast(this);
View v = View.inflate(this, R.toast_layout, null);
t.setView(v);
t.setDuration(Toast.LENGTH_LONG);
t.show();
t.show();
t.show();

 By calling show() method more than once, I hoped this would give a
 similar effect to lasting for longer time with some flickering, but I
 didn't see any difference.
 Is there some limit to the number of times that show() method can be
 called on the same Toast? e.g. just once per toast instance and
 further calling has no effect?

 Any ideas to increase that duration?

 Thank you.
 



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---