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

  • Home
  • SEARCH
  • 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 6762013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:15:45+00:00 2026-05-26T14:15:45+00:00

I am trying to construct a ListActivity that uses a listview to display a

  • 0

I am trying to construct a ListActivity that uses a listview to display a list of friends and their associated status (ie single, in a relationship).

So far, I have an ArrayAdapter set like so:

Friend[] friendList = new Friend[] {
    new Friend("john doe", "single"), 
    new Friend("jane doe", "married")
};

setListAdapter(new ArrayAdapter<Friend>(this, R.layout.portal_listview, friendList));

I would like each item in the listview to display as such:

1name: john doe
status: single

2name: jane doe
status: married

  • 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-26T14:15:45+00:00Added an answer on May 26, 2026 at 2:15 pm

    Create you own CustomArrayAdapter which extends ArrayAdapter and overwrite the View getView(int position, View convertView, ViewGroup parent) method

    I could be something like this

    public class FriendAdapter extends ArrayAdapter<Friend>{
        private Context context;
        private int resource;
        private ArrayList<Friend> friends;
    
        public FriendAdapter(Context context, int resource, ArrayList<Friend> friends) {
            super(context, resource, objects);
            this.context = context;
            this.resource = resource;
            this.friends = friends;
        }
    
    @Override
        public View getView(int position, View convertView, ViewGroup parent){
            View view = convertView;
            if (view == null){
                LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = vi.inflate(your_list_item_resource, null);
            }
            Friend friend = friends.get(position);
            view.setId(position);
            if (friend != null){
                TextView name = (TextView) view.findViewById(R.id.friendName);
                name.setText(friend.getName());
                TextView status = (TextView) view.findViewById(R.id.friendStatus);
                status.setText(friend.getStatus());
            }
            return view;
        }
    

    Hope this can help you.

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

Sidebar

Related Questions

I'm trying construct a PostgreSQL query that does the following but so far my
I'm trying to construct a database driven VB.Net app that pulls a list of
I am trying to construct a basic control that will display an undecorated JFrame
I'm trying to construct a query that will include a column indicating whether or
I am trying to construct a Groovy statement to find values that don't exist
I'm currently trying to construct a list of bean classes in Java from a
I am trying to construct a method that will allow me to find the
I'm trying to construct a dictionary that contains a series of sets: {Field1:{Value1, Value2,
Trying to construct a helper class that will return an arraylist, but I'm getting
I'm trying to construct a JDOQL query (using datanucleus) that will search for matches

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.