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 7571499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:41:22+00:00 2026-05-30T15:41:22+00:00

I’m populating a ListView which contains an ImageView and a TextView. It doesn’t crash,

  • 0

I’m populating a ListView which contains an ImageView and a TextView. It doesn’t crash, but doesn’t show anything either. I see a lot of tutorials but appear to show the same code as I am using.

This is the row.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/fondo_fila_click"
    android:orientation="horizontal"
    android:padding="5dip" >

    <LinearLayout android:id="@+id/thumbnail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="3dip"
        android:layout_alignParentLeft="true"
        android:background="@drawable/borde_foto"
        android:layout_marginRight="5dip">

        <ImageView
            android:id="@+id/imagen_marca"
            android:layout_width="50dip"
            android:layout_height="50dip"/>

    </LinearLayout>

    <TextView
        android:id="@+id/nombre"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/thumbnail"
        android:layout_toRightOf="@+id/thumbnail"
        android:textColor="#040404"
        android:typeface="sans"
        android:textSize="15dip"
        android:textStyle="bold"/>


</RelativeLayout>

And the code:

   public class SATActivity extends SherlockListActivity {

private IconListViewAdapter adaptador;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);  

        ArrayList m_fabricante = new ArrayList();
        this.adaptador = new IconListViewAdapter(this, R.layout.fila, m_fabricante);
        setListAdapter(this.adaptador);         
        iniciaFabricantes();         
    }

    @SuppressWarnings("unchecked")
    private void iniciaFabricantes() {
        ArrayList m_fabricante = new ArrayList();

        try {
            Fabricante acer = new Fabricante();
            acer.setNombre("Acer");
            acer.setFoto(R.drawable.acer);
            Fabricante apple = new Fabricante();
            apple.setNombre("Apple");
            apple.setFoto(R.drawable.apple);

            m_fabricante.add(acer);
            m_fabricante.add(apple);
        } catch (Exception e) {

        }

        adaptador.notifyDataSetChanged();
    } 

    public class IconListViewAdapter extends ArrayAdapter<Fabricante> {

        private ArrayList<Fabricante> items;

        public IconListViewAdapter(Context context, int textViewResourceId, ArrayList<Fabricante> items) {
            super(context, textViewResourceId, items);
            this.items = items;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View v = convertView;
            if (v == null) {
                LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.row, null);
            }

            Fabricante o = items.get(position);
            if (o != null) {

                //poblamos la lista de elementos

                TextView tt = (TextView) v.findViewById(R.id.nombre);
                ImageView im = (ImageView) v.findViewById(R.id.imagen_marca);

                if (im!= null) {
                    im.setImageResource(o.getFoto());
                }      

                if (tt != null) {             
                    tt.setText(o.getNombre());                             
                }                                                       
            }
            return v;
        }
    }   
}

Does anyone know why it doesn’t show the text or the images?

Thanks

  • 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-30T15:41:23+00:00Added an answer on May 30, 2026 at 3:41 pm

    Try changing your adapter class to below one:

    public class IconListViewAdapter extends ArrayAdapter<Fabricante> {
    
            private ArrayList<Fabricante> items;
            LayoutInflater mInflater;
    
            public IconListViewAdapter(Context context, int textViewResourceId, ArrayList<Fabricante> items) {
                super(context, textViewResourceId, items);
                this.items = items;
                mInflater = LayoutInflater.from(context);
            }
    
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
    
                final ViewHolder holder; 
    
                if (convertView == null) {
                    convertView = mInflater.inflate(R.layout.row, null);
                    holder = new ViewHolder();
    
                    holder.mTextView=(TextView)convertView.findViewById(R.id.nombre);
                    holder.mImageView=(ImageView)convertView.findViewById(R.id.imagen_marca);
                    convertView.setTag(holder);
                }
                else
                    holder=(ViewHolder)convertView.getTag();
    
                Fabricante o = items.get(position);
                if (o != null) {
    
                    //poblamos la lista de elementos
    
                    holder.mImageView.setImageResource(o.getFoto());
    
                    holder.mTextView.setText(o.getNombre());                             
    
                }
                return convertView;
            }
            static class ViewHolder
            {                
                TextView mTextView;
                ImageView mImageView;
            }    
    
        }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from

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.