Help with Toast

Put your problem here if it does not fit any of the other categories.

Help with Toast

Postby Teikan » Wed Jan 28, 2009 5:44 pm

I can't seem to find a way to get the setDuration() to actually set a longer duration. Here's the code I've been using:


Toast toast = new Toast(this);
toast.setView(view);
toast.setDuration(Toast.LENGTH_LONG);
toast.setGravity(191, 94, 191);
toast.show();

I want to increase the time beyond the LENGTH_LONG string. How do I accomplish that?
Teikan
Freshman
Freshman
 
Posts: 9
Joined: Wed Jan 28, 2009 5:38 pm

Top

Postby Quetzalcoatl » Wed Jan 28, 2009 6:31 pm

Have you tried using your own value instead of LENGTH_LONG?

toast.setDuration(100000); //be careful as I'm not sure whether it's milliseconds or ?
Image
Quetzalcoatl
Senior Developer
Senior Developer
 
Posts: 129
Joined: Sat Oct 18, 2008 8:21 pm
Location: near Manchester, UK

Postby Teikan » Wed Jan 28, 2009 6:37 pm

Quetzalcoatl wrote:Have you tried using your own value instead of LENGTH_LONG?

toast.setDuration(100000); //be careful as I'm not sure whether it's milliseconds or ?


Yes I have, but the strange thing is it doesn't seem to impact the time at all. The LENGTH strings do (long and short) but the numerical values don't seem to affect it at all. It seems like there is a default duration and it uses that instead of the one in the setDuration().
Teikan
Freshman
Freshman
 
Posts: 9
Joined: Wed Jan 28, 2009 5:38 pm

Postby MrSnowflake » Thu Jan 29, 2009 9:54 am

Well, it's definately not in milliseconds. I don't think you can display it any longer than _LONG, because LENGTH_LONG = 1 and LENGTH_SHORT = 0, so I think it only supports 2 lengths. For long toasts, you need to implement it yourself.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Teikan » Thu Jan 29, 2009 3:01 pm

MrSnowflake wrote:Well, it's definately not in milliseconds. I don't think you can display it any longer than _LONG, because LENGTH_LONG = 1 and LENGTH_SHORT = 0, so I think it only supports 2 lengths. For long toasts, you need to implement it yourself.


I'm still basically a novice when it comes to programming for the android and for Java, so how would i go about doing the implementation? What would the code look like?
Teikan
Freshman
Freshman
 
Posts: 9
Joined: Wed Jan 28, 2009 5:38 pm

Postby ashish » Tue Mar 10, 2009 10:55 am

u can do one thing instead of using one toast use multiple toast in one line....it will work but with slight blink


Toast.makeText(Googlemap.this, "ashish",Toast.LENGTH_LONG).show();
Toast.makeText(Googlemap.this, "ashish",Toast.LENGTH_LONG).show();
Toast.makeText(Googlemap.this, "ashish",Toast.LENGTH_LONG).show();
Toast.makeText(Googlemap.this, "ashish",Toast.LENGTH_LONG).show();
ashish
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Fri Feb 20, 2009 8:09 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 18 guests