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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:15:39+00:00 2026-05-27T00:15:39+00:00

I want to create a custom adapter for my list view. Is there any

  • 0

I want to create a custom adapter for my list view. Is there any article that can walk me through how to create one and also explain how it works?

  • 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-27T00:15:40+00:00Added an answer on May 27, 2026 at 12:15 am
    public class ListAdapter extends ArrayAdapter<Item> {
    
        private int resourceLayout;
        private Context mContext;
    
        public ListAdapter(Context context, int resource, List<Item> items) {
            super(context, resource, items);
            this.resourceLayout = resource;
            this.mContext = context;
        }
    
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
    
            View v = convertView;
    
            if (v == null) {
                LayoutInflater vi;
                vi = LayoutInflater.from(mContext);
                v = vi.inflate(resourceLayout, null);
            }
    
            Item p = getItem(position);
    
            if (p != null) {
                TextView tt1 = (TextView) v.findViewById(R.id.id);
                TextView tt2 = (TextView) v.findViewById(R.id.categoryId);
                TextView tt3 = (TextView) v.findViewById(R.id.description);
    
                if (tt1 != null) {
                    tt1.setText(p.getId());
                }
    
                if (tt2 != null) {
                    tt2.setText(p.getCategory().getId());
                }
    
                if (tt3 != null) {
                    tt3.setText(p.getDescription());
                }
            }
    
            return v;
        }
    
    }
    

    This is a class I had used for my project. You need to have a collection of your items which you want to display, in my case it’s <Item>. You need to override View getView(int position, View convertView, ViewGroup parent) method.

    R.layout.itemlistrow defines the row of the ListView.

    <?xml version="1.0" encoding="utf-8"?>
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="wrap_content" android:orientation="vertical"
        android:layout_width="fill_parent">
    
        <TableRow android:layout_width="fill_parent"
                  android:id="@+id/TableRow01"
                  android:layout_height="wrap_content">
    
            <TextView android:textColor="#FFFFFF"
                      android:id="@+id/id"
                      android:layout_width="fill_parent"
                      android:layout_height="wrap_content"
                      android:text="id" android:textStyle="bold" 
                      android:gravity="left"
                      android:layout_weight="1" 
                      android:typeface="monospace"
                      android:height="40sp" />
        </TableRow>
    
        <TableRow android:layout_height="wrap_content"
                  android:layout_width="fill_parent">
    
            <TextView android:textColor="#FFFFFF" 
                      android:id="@+id/categoryId"
                      android:layout_width="fill_parent"
                      android:layout_height="wrap_content"
                      android:text="categoryId" 
                      android:layout_weight="1" 
                      android:height="20sp" />
    
            <TextView android:layout_height="wrap_content"
                      android:layout_width="fill_parent" 
                      android:layout_weight="1"
                      android:textColor="#FFFFFF"
                      android:gravity="right"
                      android:id="@+id/description"
                      android:text="description" 
                      android:height="20sp" />
        </TableRow>
    
    </TableLayout>
    

    In the MainActivity define ListViewlike this,

    ListView yourListView = (ListView) findViewById(R.id.itemListView);
    
    // get data from the table by the ListAdapter
    ListAdapter customAdapter = new ListAdapter(this, R.layout.itemlistrow, List<yourItem>);
    
    yourListView .setAdapter(customAdapter);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a custom MSBuild task that changes my .cs files before
I want to create a custom set that will automatically convert objects into a
I want to create a custom property on one of my entities mapped from
I want to create a custom list in Flex for an interface prototype. The
I want to create a custom alert view within my iOS application. For example,
I want to create a custom style for an activity that will look like
I have created one gridview and use custom adapter for that. I added two
What I'm looking to do is create a custom controller list that displays a
I have a ListView with a custom list adapter (that extends BaseAdapter). My list
Here is a short List activity that calls a custom adapter to show class

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.