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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:37:14+00:00 2026-06-06T20:37:14+00:00

I have class Person class person{ int ID ; sting FirstName ; string Last

  • 0

I have class Person

class person{
int ID ;
sting FirstName ;
string Last Name ;
String Telephone ;

}

and I have ArrayList<person> ;

now I want to display simple list view containing just FirstName + "," + "LastName"

so I can use code like

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Select Color Mode");

ListView modeList = new ListView(this);
String[] stringArray = new String[] { "Bright Mode", "Normal Mode" };
ArrayAdapter<String> modeAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, stringArray);
modeList.setAdapter(modeAdapter);

builder.setView(modeList);
final Dialog dialog = builder.create();

dialog.show();

so how to cconvert the ArrayList to string[] that contains the format FirstName + "," + "LastName"

I can loop , but Is there any good way or simple way to do that , because I tried to use adapter but it failed to appear in the dialoge

  • 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-06T20:37:16+00:00Added an answer on June 6, 2026 at 8:37 pm

    Make your ArrayAdapter to use the type person and not String (also, just pass the ArrayList<person> instead of an array) like this:

    ArrayAdapter<person> modeAdapter = new ArrayAdapter<person>(this, android.R.layout.simple_list_item_1, android.R.id.text1, theArrayList);
    

    and then override the person‘s class toString method:

    class person {
            int ID;
            String FirstName;
            String LastName;
            String Telephone;
    
            @Override
            public String toString() {          
                return "Whatever " + FirstName + " and Whatever  " + LastName;
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have class Person { public Person(int age, string name) { Age
I have the following Scala class: case class Person(firstName: String, lastName: String, age: Int)
I have a class Person and a class Name. Name contains two Strings firstName
Say I have a list of Person objects: class person { int id; string
Consider this class: case class Person(val firstName: String, val lastName: String, age: Int) val
I have 2 classes. public class Name { public string FirstName { get; set;
For example I have a simple class like public class Person{ public int Age
public class Person { public int Id { get; set; } public string FirstName
I have a class Person i.e. the definition of Person with name and age.
I have a class like this, public class person { name Name {set; get;}

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.