tags:

views:

45

answers:

2

Ok, I have 1 custom toast (xml layout) and it works great:

    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.toast_layout));
    ImageView image = (ImageView) layout.findViewById(R.id.logo);        
    image.setImageResource(R.drawable.logo);
    title = (TextView) layout.findViewById(R.id.title);        
    txt = (TextView) layout.findViewById(R.id.text);
    toast = new Toast(appContext);
    toast.setGravity(Gravity.FILL_HORIZONTAL|Gravity.BOTTOM, 0, 0);
    toast.setDuration(Toast.LENGTH_LONG);
    toast.setView(layout);        

But when I try to make 2nd one same way I get error "Source not found" which doesn't really tell me anything about what's wrong.

    LayoutInflater infl = getLayoutInflater();
    View lay = infl.inflate(R.layout.toast_arrows, (ViewGroup) findViewById(R.id.toast_lay));                        
    toastarrows = new Toast(appContext);
    toastarrows.setGravity(Gravity.FILL_HORIZONTAL|Gravity.CENTER, 0, 0);
    toastarrows.setDuration(Toast.LENGTH_SHORT);
    toastarrows.setView(lay);                
    toastarrows.show();

I'd like those 2 toasts to appear almost same time in different places of the screen. Anyone can tell me please what's wrong with this code?

A: 

you are sure that you can show 2 Toast at the same time? i'm not sure about this, i tried it but i can display only one Toast. you have tried to show only the second one?

DX89B
I gave up and reformatted the 1st one to show both. Now fighting with complicated XML layout ;) 2nd one alone works, but shows only after the 1st one ends.
yosh
so we can add only one Toast at the time :) maybe Toast class use some static method and variable so we can't modify it at the same time. :)
DX89B
A: 

It seems that if you do really create two toasts at the sametime they will still be shown one after another in the same place. So I think your stuggling's vain.

Vladimir Ivanov