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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:05:16+00:00 2026-06-14T00:05:16+00:00

I’m trying to create a listView so that each item inside the list is

  • 0

I’m trying to create a listView so that each item inside the list is composed of a TextView and one (or more) ImageView.

So far I’ve managed to get the listView to work with items that are only TextViews by using a ArrayList<String> and a ArrayAdapter<String>adapter.

Is there a way to achieve what I want? And would other ways be easier? (Like using TableRows, but I’m not sure if they can be configured to have the onClickListener)

  • 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-06-14T00:05:17+00:00Added an answer on June 14, 2026 at 12:05 am

    Create a `list_items.xml` with a layout like this:

    <LinearLayout
        android:orientation="horizontal"
        [...]
         <ImageView
            [...]
            android:id="@+id/myimage"/>
         <TextView
            [...]            
            android:id="@+id/mytext"/>
    </LinearLayout>
    

    Then create a BaseAdapter:

      class MyAdapter extends BaseAdapter {
    
         private Context context;
         private LayoutInflater inflater;
         private ViewHolder holder;
         private ArrayList<HashMap<String, String>> data;
    
         public MyAdapter(Context context, ArrayList<HashMap<String, String>> data) {
             this.context = context;
             this.data = data;
             inflater = LayoutInflater.from(context);
         }
    
         // Below the Magic
         public View getView(int position, View convertView, ViewGroup parent) {
             inflater = (LayoutInflater)    context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    
              if(convertView == null || convertView.getTag() == null) {
                  // Here you load the list_items.xml an inflate your Layout with it
                  convertView = inflater.inflate(R.layout.list_items, null);
    
                  holder = new ViewHolder();
                  holder.text = (TextView) convertView.findViewById(R.id.mytext);
                  holder.image = (ImageView) convertView.findViewById(R.id.myimage);
    
                  convertView.setTag(holder);
    
               } else {             
                  holder = (ViewHolder) convertView.getTag();
               }
    
               // We get the HashMap for our current Position in the ListView 
               row = data.get(position);
    
               if(row != null) {
                   holder.text.setText(row.get("test"));
                   // Below could be setImageBitmap, setImageResource,...
                   // depends on how you get your image
                   holder.image.setImageBitmap(getImage(row.get("image"));
               }
    
               return convertView;
           }
    
           class ViewHolder {
               TextView text;
               ImageView image;
           }
    
     }
    
     public getImage(String image) {
          // Get your image from where you want it SD, drawable, internet)
     }
    

    An call it like this:

    MyAdapter myAdapter = new MyAdapter(this, data);
    myListView.setAdapter(myAdapter);
    

    I am assuming that your pass your data in an ArrayList containing a HashMap for each row:

       #ListItem1 = data(0) - data.get(0).get("title"), data.get(0).get("image")
       #ListItem2 = data(1) - data.get(1).get("title"), data.get(1).get("image")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I am reading a book about Javascript and jQuery and using one of the

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.