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. MapsApplication missing from source code?

It's not part of the Android platform, it's a Google-proprietary
add-on that is not open-source.

JBQ










-- 
Jean-Baptiste M. "JBQ" Queru
Android Engineer, Google.

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

2. Translators for German, Polish and Spanish

Trafficman Maps is in need of translators for German, Polish and
Spanish for Trafficman Maps 1.0. Attribution as translator is offered
as compensation for use of your translation. If interested, please
email.

Cheers,
Wes

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

3. Help needed regarding Maps application in Emulator

4. Finding the data directory of an application

5. Using make-live script for USB HDD

6. Not able to build Browser Source Code on android-sdk-windows-1.0_r1

7. enabling OTA updates for my device