cannot set image while inflating layout on android

I am trying to add a small image in a row of my ExpandableList. Below you can see the code of the getchildview method of my custom adapter. It works perfectly for setting dynamic text but it fails when i want to add an image.

I don't understand why the commands for adding an image are completely ignored by the application. I have tried 2 versions, just to see both fail.

I do not get any runtime error, just the images aren't loaded. Moreover, i know that at least "setImageBitmap" works because i use it elsewhere with success.

The images referenced are 9x10 png files.

Please help me because i don't think i am missing anything but the images aren't shown at all.

I have tried to set a background color (setBackgroundColor) on relativelayout l but it didn't have effect too. So i think it is something graphic related, but i can't find any error in my approach.

public View getChildView(int groupPosition, int childPosition,
            boolean isLastChild, View convertView, ViewGroup parent) {
        RelativeLayout l = (RelativeLayout) getLayoutInflater().inflate(R.layout.titoli2_gruppo_riga, null)
        String s;
        Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.disponibile);
            ((ImageView) l.findViewById(;
            ((ImageView) l.findViewById(;           
        ((TextView) l.findViewById([DES]);
        ((TextView) l.findViewById("€"+prodotti.get(groupPosition).get(childPosition)[PRE]);
        ((TextView) l.findViewById([NOT]);                
        ((TextView) l.findViewById([SIG]);

        return l;

You can see the XML i am inflating, here


Did you checked you Graphical Layout in you XML file, Image is not visible in you Graphical Layout because of TextView with id as tgr_descr is given match_parent so you Imageview is not Visible.

For Checking whether image is visible just use android:src="@drawable/icon"

Try this Code :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=""
               android:layout_height="fill_parent" android:weightSum="1">
<ImageView      android:id="@+id/tgr_dispon"  android:layout_height="wrap_content"
                android:layout_width="wrap_content" android:layout_toLeftOf="@+id/tgr_descr"
                android:layout_alignParentLeft="true" android:paddingLeft="7dp"
<TextView       android:id="@+id/tgr_descr" android:layout_height="wrap_content"
                android:layout_width="wrap_content"  android:layout_alignParentTop="true"
                android:layout_toLeftOf="@+id/tgr_prezz" android:text="descr"
                android:textAppearance="?android:attr/textAppearanceMedium" android:padding="7dp"/>

<TextView       android:id="@+id/tgr_prezz" android:layout_height="wrap_content"
                android:layout_width="wrap_content" android:layout_alignParentTop="true"
                android:layout_alignParentRight="true"  android:text="prezzo"
                android:textAppearance="?android:attr/textAppearanceMedium" android:padding="7dp"/>

<TextView       android:id="@+id/tgr_note" android:layout_height="wrap_content"
                android:layout_width="wrap_content" android:layout_below="@+id/tgr_descr"
                android:layout_alignParentLeft="true" android:text="note"
                android:textAppearance="?android:attr/textAppearanceSmall" android:paddingLeft="7dp"/>
<TextView       android:id="@+id/tgr_sigla" android:layout_height="wrap_content"
                android:layout_width="wrap_content"  android:layout_toRightOf="@+id/tgr_note"
                android:layout_below="@+id/tgr_descr" android:layout_alignParentRight="true"
                android:text="sigla" android:textAppearance="?android:attr/textAppearanceSmall"

Need Your Help

Can't insert values into MSSQL with PDO

php sql-server pdo

I'm using PDO to communicate with my database from PHP code and i have the following code:

404 Http error handler in Asp.Net MVC (RC 5) http http-status-code-404

How can I Handler 404 errors without the framework throwing an Exception 500 error code?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.