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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:40:09+00:00 2026-05-20T16:40:09+00:00

I want to create list with different types of items. They should call different

  • 0

I want to create list with different types of items. They should call different intents or do other things (display a map etc.) . It should act like contact details. Numbers of items and actions is predefined.

conact dteails

How to achieve this effect elegantly? I don’t need exact code but guidelines and information where to look. Any help will be appreciated 🙂


UPDATE:

By “this effect” I mean creating a list of different types of items (onClickListener, layout). On picture above you can see that you have a contact with various options: calling somebody, emailing, chatting, looking at google maps etc. All of those options are grouped at list.

I’m wondering if it could be achieved by xml layout without defining custom Adapter class. I want also be able to add some static header rows with eg. category name.

  • 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-20T16:40:09+00:00Added an answer on May 20, 2026 at 4:40 pm

    The only way I see to achieve this would be to indeed create a custom adapter class.
    I’m using this to create a file browsers, with different actions based on wether the item selected is a file or a folder.

    Basically, You need to create a custom adapter extending ArrayAdapter (you can use another base class if all your items inherit from the same class). Here’s a sample code :

    public class MyCustomAdapter extends ArrayAdapter<Object> {
    
    
        public MyCustomAdapter(Context context, int textViewResourceId,
                ArrayList<Object> objects) {
            super(context, textViewResourceId, objects);
            mList = objects;
        }
    
    
        public View getView(int position, View convertView, ViewGroup parent) {
            Object obj = mList.get(position);
            View v = convertView;
            LayoutInflater vi = (LayoutInflater) mContext
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
    
            if (obj.getClass().isAssignableFrom(MyClass1.class)){
                v = vi.inflate(R.layout.myclass1_item_layout, null);
                setupViewClass1(obj,v);
            } else if (obj.getClass().isAssignableFrom(MyClass2.class)){
                v = vi.inflate(R.layout.myclass2_item_layout, null);
                setupViewClass2(obj,v);
            }
    
            return v;
        }
    
        private void setupViewClass1 (Object obj, View v){  
            // setup the content of your view (labels, images, ...)
        }
    
        private void setupViewClass2 (Object obj, View v){  
            // setup the content of your view (labels, images, ...)
        }
    
        private ArrayList<Object> mList;
    
    }
    

    Then you need to add an OnItemClickListener as well as an OnCreateContextMenuListener to handle the click and longpress event on your list, again making a filter on the class of your object.

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

Sidebar

Related Questions

I`v come across a need where I want to create multiple list items from
I want to create a class that can take different types of value in
I want to create a function that can take different types of iterators which
I want to create a list of items and have a hyperlink on each
I want to create an IList of objects that are all different concrete types,
I want to create a list of columns in SQL Server 2005 that have
I want to create a list of integers from 1 to n . I
I want to create a list of methods to execute. Each method has the
I want to create a List of KeyValuePair s in a managed C++ project.
I want to create a list of category terms (contained within a block), with

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.