How to creat Toast Like view

by Tushar » Wed, 11 Mar 2009 16:16:51 GMT


Sponsored Links
 Hi,

Using android.widget.Toast one can created  floating view over the
application. I would like to created similar view which will float on
top of all running applications at a specified location. Any thoughts
on what should I need to do for this. I tried to created activity by
setting
android:windowIsFloating ="true" , but didn't worked out.


Any suggestions ?
--~--~---------~--~----~------------~-------~--~----~



How to creat Toast Like view

by Gulfam » Wed, 11 Mar 2009 20:26:20 GMT


 Hi Tushar

You can make toast like this

public void showAlertMessage(Context context, String text){

        LayoutInflater inflater = (LayoutInflater)context.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.toast_layout, null);
        // set the text in the view
        TextView message = (TextView) view.findViewById(R.id.toast_message);
        message.setText(text);
        ImageView image = (ImageView)view.findViewById(R.id.toast_image);
        image.setImageResource(R.drawable.logo_icon);

        Toast toast = new Toast(context);
        toast.setView(view);
        toast.setDuration(Toast.LENGTH_LONG);
        toast.show();


    }


AND XML would be like this

<?xml version="1.0" encoding="utf-8"?>


        <FrameLayout
                        
xmlns:android=" http://schemas.android.com/apk/res/android" ;
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:background="@android:drawable/toast_frame">

        <LinearLayout
                        android:orientation="horizontal"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content">

        <ImageView
                android:id="@+id/toast_image"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"/>
                                <!-- android:src="@drawable/vopium_logo_icon"
                        /> -->

        <TextView
                        android:id="@+id/toast_message"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"/>

                </LinearLayout>
        </FrameLayout>
*********************************************
another way to make toast is

Toast.makeText(context,"Any String",Toast.LENGTH_LONG).show();

Hope fully it will help u

Regards
Gulfam



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


How to creat Toast Like view

by mark . kahrl » Fri, 13 Mar 2009 06:31:31 GMT


 Did you look at PopupWindow in the /widgets package? it is toast
like, but persist until the user closes it.


                    Mark




--~--~---------~--~----~------------~-------~--~----~



How to creat Toast Like view

by gymshoe » Fri, 13 Mar 2009 11:13:36 GMT


  http://www.anddev.org/2_ways_to_implement_a_toast-t3164.html 




--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. getDuration() in VideoView returns -1 !!!

Hi,

Has anyone tried using the getDuration() method in VideoView? It
returns a -1 for me always. Is there a way around?

Thanks,

Abhi

-- 

2. Google Maps API: ItemizedOverlay

Hi,

I read the doc "HelloMapView" just to know how to add markers to a map
view. The API reference says this about ItemizedOverlay class:

"A base class for an Overlay which consists of a list of OverlayItems.
This handles sorting north-to-south for drawing, creating span bounds,
drawing a marker for each point, and maintaining a focused item. It
also matches screen-taps to items, and dispatches Focus-change events
to an optional listener. "

It crearly stands that consists of a list of OverlayItems. Each
OverlayItem has a method to set a marker that it's a Drawable object:
setMarker(Drawable marker). Following the HelloMapView tutorial you
can see how to add more than one item to the ItemizedOverlay for being
displayed on the map. What you inmediately see is that the same marker
is being shown on the map.

The question is: can we change that behaviour for displaying the
marker that each OverlayItem has?

I have test the following without success (modifying the HelloMapView code):

Drawable d1 = ...getDrawable(R.drawable.androidmarker);
Drawable d2 = ...getDrawable(R.drawable.mymarker);

itemizedOverlay = new HelloItemizedOverlay(d1);

GeoPoint point = new GeoPoint(19240000,-99120000);
OverlayItem overlayitem = new OverlayItem(point, "", "");

GeoPoint point2 = new GeoPoint(35410000, 139460000);
OverlayItem overlayitem2 = new OverlayItem(point2, "", "");
overlayitem2.setMarker(d2);

itemizedOverlay.addOverlay(overlayitem);
itemizedOverlay.addOverlay(overlayitem2);
mapOverlays.add(itemizedOverlay);


The result is: The android marker keeps showing on the map, but the
"new" marker don't. If I remove or comment the line:

overlayitem2.setMarker(d2);

then both android marker (in fact is just one) are shown in the map.

Is this the only scope of ItemizedOverlay? Can't be, what's the reason
then despite of having events on the items? Such a boring class if it
is so...

Regards,
-- 
If you want freedom, compile the source. Get gentoo.

Sebastin Treu
http://labombiya.com.ar

-- 

3. Programmatically remove permission

4. Moving CursorAdapter cursor creation to background thread

5. Dual Sim Dual Standby management in Android ?

6. Moving CursorAdapter cursor creation to background thread

7. Animation Jerking when background operation running