Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6208271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:46:50+00:00 2026-05-24T05:46:50+00:00

I want to show an image in a Toast in Android. In my layout.xml,

  • 0

I want to show an image in a Toast in Android. In my layout.xml, I have defined a LinearLayout ‘svllid’, that contains a textview and a tablelayout, like so:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#CCCCCC"
    android:weightSum="1" android:id="@+id/llid">
    <EditText  
        android:id="@+id/cpuText"  
        android:hint="Enter cpu" 
        android:layout_height="wrap_content"   
        android:layout_width="fill_parent">  
    </EditText>
    <EditText  
        android:id="@+id/ramText"  
        android:hint="Enter ram" 
        android:layout_height="wrap_content"    
        android:layout_width="fill_parent">  
    </EditText> 
    <EditText  
        android:id="@+id/bandwidthText"  
        android:hint="Enter bandwidth" 
        android:layout_height="wrap_content"    
        android:layout_width="fill_parent">  
    </EditText> 
    <Button  
        android:id="@+id/imageRequestButton"  
        android:layout_height="wrap_content"  
        android:text="Download"   
        android:layout_width="fill_parent" android:onClick="sendImageRequest">  
    </Button>       
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#00FF00"
        android:weightSum="1" android:id="@+id/svllid">
        <TextView android:text="client profile"
            android:id="@+id/profileName"
            android:layout_width="fill_parent"
            android:textStyle="bold"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:background="#000000">
        </TextView> 
        <TableLayout
            android:paddingBottom="3pt"  
            android:background="#0000FF"
            android:layout_width="fill_parent" 
            xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content">
            <TableRow>
                <TextView
                    android:paddingLeft="3pt" 
                    android:paddingTop="3pt" 
                    android:text="Image Name"
                    android:layout_width="150px"
                    android:layout_height="wrap_content" 
                    android:textColor="#FFFFFF"/>
                <TextView
                    android:paddingLeft="3pt" 
                    android:text="blah.png"
                    android:textColor="#FFFFFF"
                    android:layout_width="315px"
                    android:layout_height="wrap_content" android:id="@+id/imageName"/>          
            </TableRow>
            <TableRow>
                <TextView
                    android:paddingLeft="3pt" 
                    android:text="Size"
                    android:layout_width="150px"
                    android:layout_height="wrap_content" 
                    android:textColor="#FFFFFF"/>
                <TextView
                    android:paddingLeft="3pt" 
                    android:text="155kb"
                    android:textColor="#FFFFFF"
                    android:layout_width="300px"
                    android:layout_height="wrap_content" android:id="@+id/imageSize"/>          
            </TableRow> 
            <TableRow>
                <TextView
                    android:paddingLeft="3pt" 
                    android:text="Dimensions"
                    android:layout_width="150px"
                    android:layout_height="wrap_content" 
                    android:textColor="#FFFFFF"/>
                <TextView
                    android:paddingLeft="3pt" 
                    android:text="250 X 150px"
                    android:textColor="#FFFFFF"
                    android:layout_width="300px"
                    android:layout_height="wrap_content" android:id="@+id/imageDimension"/>         
            </TableRow>                         
        </TableLayout>                                          
    </LinearLayout>
</LinearLayout>

I want to show the LinearLayout with id ‘svllid’ in a Toast and show the toast from my activity code.

Now, in the actual android code, I first call

setContentView(R.layout.main); 

Subsequently, I read an image from a soap message. I then create an ImageView and I want to insert it into the LinearLayout ‘svllid’ and show that LinearLayout in an Android Toast.

                Toast imageToast = new Toast(this);
                LinearLayout toastLayout = (LinearLayout) findViewById(R.id.svllid);
                toastLayout.addView(image,1);
                imageToast.setView(toastLayout);
                imageToast.setDuration(Toast.LENGTH_LONG);
                imageToast.show();

However, it won’t work. My application crashes with the error:

java.lang.IllegalArgumentException: View not attached to window manager

Any ideas why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:46:51+00:00Added an answer on May 24, 2026 at 5:46 am

    I believe you have to use a specific ID for the root layout. You have to name it “toast_layout” or “toast_layout_root” (not sure which one has to be used- the documentation is slightly ambigious there, try both).

    And as Varun said you need to put the layout in its own layout file.

    Read the Android Doc’s and follow the given example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to show an image view for three like on/off,if any one have
I want to show the image that mobile phone's camera its taking on a
I want to show an image on my report if that image exists in
I have a site for which i want to show a image in india
Following is my listview layout. Now I have a image and textview in my
I want to show image in a crystal report. Scenario is something like this.
When I want to show an image I use something like this: public ActionResult
I need a jquery slideshow with div popup i want to show my image
I am new to web development / php. I want to show an image
I want to show a loading image after page submit. I want it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.