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. Adapter fetches and parses RSS feed to get its data - best practice?

In a shared project, we have an Adapter class (extends BaseAdapter,
implements ListAdapter). In its constructor, this class fetches an RSS
feed from the internet and parses the returned XML document to obtain
the data it will 'adapt'; the data is kept in a private class
variable.

This is seen as the "Android way" of doing things by the author and is
supported by the project lead.
Can this be considered a "Best Practice"?
Can it be justified on the grounds that it (may?) increase
performance?
Doesn't it violate the general Object Oriented Design (OOD) principle
that a class should have only a "Single Responsiblity"?
Are best practices for OOD or Java to be set aside in Android
development?

-- 

2. Not installed

Kenapa ya pas mau install beberapa apk selalu gagal dan muncul "application
not installed" device csl andropad....mohon info

-- 
===============
"

3. [WTA][HELP]hh restart setelah mencet search button

4. [wta]koneksi internet tri bermasalah?

5. multiple threads problem, possible memory leak

6. RIL-deamon not getting started

7. How to communicate between Activities/Services